3

is it possible to put a unicode character in the codepane in Excel 2013?

Like this:

Select Case Work(str)
   Case "◊ Engineering", "◊ Woodworking", "◊ Technician"
   'Do Something
End Select
trill
  • 148
  • 2
  • 9
  • Note: UTF-8 is one of several character encodings for the Unicode character set. Another is UTF-16. Excel and VBA use UTF-16 natively (since the 1990s). (But unfortunately, as you've found, the VBA editor does not use Unicode). Therefore, this question has nothing to do with UTF-8. – Tom Blodget Apr 15 '18 at 13:24
  • Does this answer your question? [How to type Unicode currency character in Visual Basic Editor](https://stackoverflow.com/questions/24384952/how-to-type-unicode-currency-character-in-visual-basic-editor) – user202729 Oct 05 '21 at 12:11

2 Answers2

7

You can use the ChrW function for that:

Select Case Work(str)
   Case ChrW(9674) & " Engineering", ChrW(9674) & " Woodworking", ChrW(9674) & " Technician"
   'Do Something
End Select

you can test this e.g. as follows:

Sheet1.[A1].Value = ChrW(9674)

This will put your character in cell A1 of Sheet1

  • The `ChrW` CharCode argument is a `Long` that identifies a character, but doesn't allow values greater than 65535 (hex value `&HFFFF`). You can find six systematic ways to overcome this restriction at [Get UniCode characters with CharCode greater hex `FFFF`](https://stackoverflow.com/questions/56008191/get-unicode-characters-with-charcode-values-greater-hex-ffff) – T.M. Nov 22 '19 at 14:58
4

You can use Chr or ChrW Functions.

The valid range for Chr is 0 through 255, and the valid range for ChrW is -32768 through 65535.

Example:

ChrW(9608)

or

ChrW(&H2588)

The &H preface says that 2588 is a hexadecimal number, which is what you find looking at charmap.

Alisson Bezerra
  • 221
  • 2
  • 13