What is the CODE function in Excel?
The CODE function is one of the TEXT functions of Excel.
It Returns a numeric code for the first character in a text string, in the character set used by your computer.
We can find this function in TEXT category of the insert function Tab.
How to use CODE function in excel
- Click on an empty cell (like F5).

2. Click on the fx icon (or press shift+F3).

3. In the insert function tab you will see all functions.

4. Select TEXT category.
5. Select CODE function
6. Then select ok.

7. In the function arguments Tab you will see CODE function.
8. Text is the text for which you want the code of the first character.
9. You will see the results in formula result section.

Examples of CODE function in Excel
Example 1:
Find the numbers of any character between (!-z) with Code function

=Code(!)----->>>>answer is 33
=Code(0)----->>>>answer is 48
=Code(?)----->>>>answer is 63
=Code(N)----->>>>answer is 78
=Code(])----->>>>answer is 93
What is the purpose of CODE function?
It Returns a numeric code for the first character in a text string, in the character set used by your computer.
What is the Return value of CODE function?
It just returns the number.
Code (text)=number
How many arguments does CODE function have?
CODE (Text)
CODE function has 1 argument.
- Text is the text for which you want the code of the first character.
Which version of excel supports CODE function?
This function is available for all excel versions (2003-2019)
Errors in CODE function
This function has no error.
Code (text)=no error
What is reverse function of CODE ?
Code and Char function are reverse of each other.
=CHAR(33)----->>>>answer is !
=Code(!)----->>>>answer is 33
What is output of CODE function If text contains more than one character ?
CODE function returns a numeric code for the first character.

=Code(2)----->>>>answer is 50
=Code(23)----->>>>answer is 50
=Code(234)----->>>>answer is 50
What is output of CODE function If text contains number ?
CODE function returns a numeric code (48-57) for the first character (0-9).

=Code(9)----->>>>answer is 57
=Code(98)----->>>>answer is 57
=Code(8)----->>>>answer is 56
CODE related functions
- Use BAHTTEXT function to Convert a number to text.
- Use CHAR function to return the character specified by the code number from the character set for your computer.
- UNICODE function
- UNICHAR function