The Excel CODE function is a Text formula that converts a specified character into the corresponding code based on the character set used by your computer. This can be useful for when you want to find out the code for a specific character, or using this value in other formulas. In this guide, we’re going to show you how to use Excel CODE function and also throw in some tips and error handling methods.
Supported versions
- All Excel versions
Excel CODE Function Syntax
Arguments
text |
The text for which you want the code of the first character. |
Examples
Basics
Begin by entering the target text for the value argument. Let's take a look at how this works on an example.
Multi-character string
If the text argument contains more than one characters, like a word or a sentence, the CODE function converts only the first character of the target string.
Both functions below will return the same result.
=CODE("s")
Tips
- The character set differs based on your operating system:
- Windows: Windows Character Set (1252)
- macOS: MAC OS Character Set
- Use the CHAR function to return the code number of a character. The CHAR function is essentially the opposite of the CODE.