What CODE does
CODE returns the numeric code for the first character in a text string. It is useful when you need to identify hidden characters, punctuation, or leading symbols that affect formulas.
Practical examples
Return the code for the first character
=CODE("A")
This returns 65, which is the code for uppercase A.
Diagnose a hidden leading character
=CODE(D3)
Use this when a cell looks blank or normal but still behaves unexpectedly, for example when a space character is causing an error.
Common mistakes and notes
CODE checks only the first character
If the problem character appears later in the string, CODE will not see it unless you isolate that position first.
The result depends on Excel's character set
Microsoft notes that the returned code corresponds to the character set used by your computer.