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.
Syntax =CODE(text)
=CODE("Austin")Arguments
| Name | Required | What to pass |
|---|---|---|
| text | Required | The text to inspect. Only the first character is used. |
Examples
The first letter of Austin
=CODE("Austin")Result 65
| A | B | |
|---|---|---|
| 1 | Text | Austin |
| 2 | Code | 65 |
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.