Excel
CODE function in Excel
Returns a numeric code for the first character in a text string
=CODE(text)CODE syntax and parameters
One argument, one required.
- textstringRequired
The text for which you want the code of the first character.
CODE examples
Formulas you'll actually reuse.
The code of the first character — 32 means a hidden leading space:
=CODE(A2)Result
32Check the last character — 160 is a non-breaking space that TRIM won't remove:
=CODE(RIGHT(A2, 1))Result
160
CODE in Google Sheets
Same name — your formula ports as-is.
Try CODE in the playground
Edit the example — nothing to install.
Preloaded with the CODE formula from Example 1 — change anything and watch it respond.
Loading the editor…
Related functions
More ways Excel gets this done.
- ARRAYTOTEXTReturns an array of text values from any specified rangeTextNo Google Sheets equivalent
- CHARReturns the character specified by the code numberTextGoogle Sheets
- CLEANRemoves all nonprintable characters from textTextGoogle Sheets
- CONCATCombines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments.TextGoogle Sheets
- CONCATENATEJoins several text items into one text itemTextGoogle Sheets
- DETECTLANGUAGEIdentifies the language of a specified textTextGoogle Sheets