Character Codes
Every character needs to be converted into a number before it can be saved.
Text is represented by assigning a numerical value to each letter, digit and symbol.
Character Encoding is the conversion of a symbol into a binary number
ASCII
The first widely adopted standard was the ASCII character set which uses the values 0 to 127 to represent the letters, numericals and commonly used punctuation marks and characters.
ASCII stands for American Standard Code for Information Interchange.
For example lowercase letters a-z are represented by the values 97-122
ASCII codes 0-31 represent non printing characters.
ASCII uses a 7-bit encoding scheme that represents 128 different numbers.
ASCII only supports one alphabet
The characters 1-9 and 11-31 and 128-159 are not supported by Windows.
| 1-9 | 58 | : | 87 | W | 116 | t | |
| 10 | 59 | ; | 88 | X | 117 | u | |
| 11-31 | 60 | < | 89 | Y | 118 | v | |
| 32 | 61 | = | 90 | Z | 119 | w | |
| 33 | ! | 62 | > | 91 | [ | 120 | x |
| 34 | " | 63 | ? | 92 | \ | 121 | y |
| 35 | # | 64 | @ | 93 | ] | 122 | z |
| 36 | $ | 65 | A | 94 | ^ | 123 | { |
| 37 | % | 66 | B | 95 | _ | 124 | | |
| 38 | & | 67 | C | 96 | ` | 125 | } |
| 39 | ' | 68 | D | 97 | a | 126 | ~ |
| 40 | ( | 69 | E | 98 | b | 127 | |
| 41 | ) | 70 | F | 99 | c | 128 | |
| 42 | * | 71 | G | 100 | d | ||
| 43 | + | 72 | H | 101 | e | ||
| 44 | , | 73 | I | 102 | f | ||
| 45 | - | 74 | J | 103 | g | ||
| 46 | . | 75 | K | 104 | h | ||
| 47 | / | 76 | L | 105 | i | ||
| 48 | 0 | 77 | M | 106 | j | ||
| 49 | 1 | 78 | N | 107 | k | ||
| 50 | 2 | 79 | O | 108 | l | ||
| 51 | 3 | 80 | P | 109 | m | ||
| 52 | 4 | 81 | Q | 110 | n | ||
| 53 | 5 | 82 | R | 111 | o | ||
| 54 | 6 | 83 | S | 112 | p | ||
| 55 | 7 | 84 | T | 113 | q | ||
| 56 | 8 | 85 | U | 114 | r | ||
| 57 | 9 | 86 | V | 115 | s |
ANSI
ASCII was then extended to include additional numbers (129 - 255).
ANSI stands for American National Standards Institute.
ANSI is also known as extended ASCII.
ANSI uses a 8-bit encoding scheme that represents 218 numbers.
Also known as Windows-1252 and was the default font used in Windows 95.
This is compatible with ASCII.
ASC - Returns the ASCII / ANSI number for the first character in a text string.
CHR - Returns the character with the corresponding ASCII / ANSI number.
| 1-9 | 58 | : | 87 | W | 116 | t | |
| 10 | 59 | ; | 88 | X | 117 | u | |
| 11-31 | 60 | < | 89 | Y | 118 | v | |
| 32 | 61 | = | 90 | Z | 119 | w | |
| 33 | ! | 62 | > | 91 | [ | 120 | x |
| 34 | " | 63 | ? | 92 | \ | 121 | y |
| 35 | # | 64 | @ | 93 | ] | 122 | z |
| 36 | $ | 65 | A | 94 | ^ | 123 | { |
| 37 | % | 66 | B | 95 | _ | 124 | | |
| 38 | & | 67 | C | 96 | ` | 125 | } |
| 39 | ' | 68 | D | 97 | a | 126 | ~ |
| 40 | ( | 69 | E | 98 | b | 127 | |
| 41 | ) | 70 | F | 99 | c | 128 | |
| 42 | * | 71 | G | 100 | d | 129 | |
| 43 | + | 72 | H | 101 | e | 130 | |
| 44 | , | 73 | I | 102 | f | 131 | |
| 45 | - | 74 | J | 103 | g | 132 | |
| 46 | . | 75 | K | 104 | h | 133 | |
| 47 | / | 76 | L | 105 | i | 134 | |
| 48 | 0 | 77 | M | 106 | j | 135 | |
| 49 | 1 | 78 | N | 107 | k | 136 | |
| 50 | 2 | 79 | O | 108 | l | 137 | |
| 51 | 3 | 80 | P | 109 | m | 138 | |
| 52 | 4 | 81 | Q | 110 | n | 139 | |
| 53 | 5 | 82 | R | 111 | o | 140 | |
| 54 | 6 | 83 | S | 112 | p | 141 | |
| 55 | 7 | 84 | T | 113 | q | 142 | |
| 56 | 8 | 85 | U | 114 | r | 143 | |
| 57 | 9 | 86 | V | 115 | s | 144 | |
| 145 | | 174 | ® | 203 | Ë | 232 | è |
| 146 | | 175 | ¯ | 204 | Ì | 233 | é |
| 147 | | 176 | ° | 205 | Í | 234 | ê |
| 148 | | 177 | ± | 206 | Î | 235 | ë |
| 149 | | 178 | ² | 207 | Ï | 236 | ì |
| 150 | | 179 | ³ | 208 | Ð | 237 | í |
| 151 | | 180 | ´ | 209 | Ñ | 238 | î |
| 152 | | 181 | µ | 210 | Ò | 239 | ï |
| 153 | | 182 | ¶ | 211 | Ó | 240 | ð |
| 154 | | 183 | · | 212 | Ô | 241 | ñ |
| 155 | | 184 | ¸ | 213 | Õ | 242 | ò |
| 156 | | 185 | ¹ | 214 | Ö | 243 | ó |
| 157 | | 186 | º | 215 | × | 244 | ô |
| 158 | | 187 | » | 216 | Ø | 245 | õ |
| 159 | | 188 | ¼ | 217 | Ù | 246 | ö |
| 160 | 189 | ½ | 218 | Ú | 247 | ÷ | |
| 161 | ¡ | 190 | ¾ | 219 | Û | 248 | ø |
| 162 | ¢ | 191 | ¿ | 220 | Ü | 249 | ù |
| 163 | £ | 192 | À | 221 | Ý | 250 | ú |
| 164 | ¤ | 193 | Á | 222 | Þ | 251 | û |
| 165 | ¥ | 194 | Â | 223 | ß | 252 | ü |
| 166 | ¦ | 195 | Ã | 224 | à | 253 | ý |
| 167 | § | 196 | Ä | 225 | á | 254 | þ |
| 168 | ¨ | 197 | Å | 226 | â | 255 | ÿ |
| 169 | © | 198 | Æ | 227 | ã | ||
| 170 | ª | 199 | Ç | 228 | ä | ||
| 171 | « | 200 | È | 229 | å | ||
| 172 | ¬ | 201 | É | 230 | æ | ||
| 173 | | 202 | Ê | 231 | ç |
UNICODE
ANSI was then extended to include additional numbers (256 - 65,535)
It was soon realised that the 255 ASCII values were not sufficient for the number of characters that computers needed to work with.
The UNICODE character set is a universal standard across all systems.
Only 39,000 of these codes are currently assigned
The UNICODE character set is a universal standard across all systems.
UNICODE uses a 8-bit encoding scheme and has different types.
The most popular type is UTF-8 which is compatible with ASCII.
Windows does support Unicode but it will depend on your regional settings.
UTF8
UTF16
ASCW - Returns the Unicode number for the first character in a text string.
CHRW - Returns the character with the corresponding Unicode number.
Hexadecimal
The first 255 characters of Unicode are the same as the first 255 characters of ANSI.
| space | %20 | : | %3A | T | %54 | n | %6E |
| ! | %21 | ; | %3B | U | %55 | o | %6F |
| " | %22 | < | %3C | V | %56 | p | %70 |
| # | %23 | = | %3D | W | %57 | q | %71 |
| $ | %24 | > | %3E | X | %58 | r | %72 |
| % | %25 | ? | %3F | Y | %59 | s | %73 |
| & | %26 | @ | %40 | Z | %5A | t | %74 |
| ' | %27 | A | %41 | [ | %5B | u | %75 |
| ( | %28 | B | %42 | \ | %5C | v | %76 |
| ) | %29 | C | %43 | ] | %5D | w | %77 |
| * | %2A | D | %44 | ^ | %5E | x | %78 |
| + | %2B | E | %45 | _ | %5F | y | %79 |
| , | %2C | F | %46 | ` | %60 | z | %80 |
| - | %2D | G | %47 | a | %61 | { | %81 |
| . | %2E | H | %48 | b | %62 | | | %82 |
| / | %2F | I | %49 | c | %63 | } | %83 |
| 0 | %30 | J | %4A | d | %64 | ~ | %84 |
| 1 | %31 | K | %4B | e | %65 | ||
| 2 | %32 | L | %4C | f | %66 | ||
| 3 | %33 | M | %4D | g | %67 | ||
| 4 | %34 | N | %4E | h | %68 | ||
| 5 | %35 | O | %4F | i | %69 | ||
| 6 | %36 | P | %50 | j | %6A | ||
| 7 | %37 | Q | %51 | k | %6B | ||
| 8 | %38 | R | %52 | l | %6C | ||
| 9 | %39 | S | %53 | m | %6D |
ASCW Bug
This returns the bit pattern for unsigned 16-bit integers.
VBA uses signed 16-bit integers so after 32767 this function will return negative numbers.
Use the following function instead
Public Function ASCW_2(ByVal sChar As String) As Integer
ASCW_2 = (ASCW(sChar) And &HFFF&)
End Function
DBCS Characters
Excel Sorting
Comparing Strings in VBA (after they have been sorted in Excel) does not work.
The ASCII code associated with the characters for VBA is not consistent with how Excel sorts a text sting on the worksheet.
![]() |
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext
