3

I have several special characters in an excel spreadsheet. How do I reference them in Excel VBA?

The characters I need are not in the standard 255 ASCII codes.

I was thinking perhaps Chr(code) would work, but I'm not able to find the codes for the characters I need to test this.

5
  • you get it using Chr(number) function. The opposite function is called Asc(string) Commented Jan 27, 2014 at 9:35
  • 2
    Goto this link to understand the codes for all characters asciitable.com Commented Jan 27, 2014 at 9:37
  • 1
    Sub GetAsciiCodes() Dim i As Long For i = 1 To 255 Range("A" & i) = i Range("B" & i) = Chr(i) Next End Sub Commented Jan 27, 2014 at 9:43
  • Nice, but I updated the question because they are non-standard ascii characters Commented Jan 27, 2014 at 9:58
  • ++ > The ChrW function returns a String containing the Unicode character except on platforms where Unicode is not supported, in which case, the behavior is identical to the Chr function. ++ > Chr function ++ ++ Use this web to search for unicode. ++ For ChrW, just use the numerics in HTML-code; dont use the Unicode number (idk why). Commented May 29, 2022 at 13:48

2 Answers 2

5

User ChrW() instead of Chr() function to reference Unicode characters:

ChrW(23383) will produce .

Chr(23383) will throw an exception.

Sign up to request clarification or add additional context in comments.

Comments

1

Use this script to see ChrW characters in F column

Sub caracter()
Dim caract As String
Dim r As Range
Dim i As Integer
caract = ChrW(633)
For i = 1 To 20000
caract = ChrW(i)
ActiveSheet.Cells(i, 6).Value = caract
Next i
End Sub

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.