Function · Convert text and numbers

Excel CODE function

The Excel CODE function returns the code of the first character. CODE("Austin") is 65, the code for A, and the rest of the word is ignored.

All current Excel versions. Also in Excel for the web and Google Sheets.

Syntax =CODE(text)

CODE
=CODE("Austin")

Arguments

NameRequiredWhat to pass
textRequiredThe text to inspect. Only the first character is used.

Examples

The first letter of Austin

=CODE("Austin")

Result 65

=CODE(B1)B2
Code
AB
1TextAustin
2Code65
A picture of the sheet, not a live calculator. CODE("a") is 97. Case matters.

CODE returns the character code of the first character and ignores the rest. Austin and A both return 65. A lowercase a returns 97. That is enough to test the case of a first letter without EXACT on the whole string, and it is the reverse of CHAR(65).

An empty cell is #VALUE!. A leading space returns 32, the code for a space, which is a quiet way to discover padding. UNICODE is the matching function when the character is outside the 255 codes CHAR understands.