I have a spreadsheet that contains emojis, e.g.,
相关问题
- Excel sunburst chart: Some labels missing
- Error handling only works once
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
相关文章
- Get column data by Column name and sheet name
- programmatically excel cells to be auto fit width
- Unregister a XLL in Excel (VBA)
- Unregister a XLL in Excel (VBA)
- How to prevent excel from truncating numbers in a
- numeric up down control in vba
- Declare a Range relative to the Active Cell with V
- What's the easiest way to create an Excel tabl
Thank you to FunThomas for pointing out that emojis are represented as 2 characters in VBA. The revised VBA code that works based on this:
In my actual solution, I put this into a loop to remove all of the different emojis.
I did as small experiment, putting your smiley into excel and let the following code run:
My result was
So obviously, the single character is split into 2 inside VBA.
AscW
and it's pendantChrW
deal with 16bit, and the emoji is a 32bit char, so in VBA this emoji character is handled as if there are 2 characters in the stringI added the following code and voilà, the smiley char was gone:
Probably you have to experiment with the different emojis you are facing and build a list in your replacing routine.