Exceljet

Quick, clean, and to the point

Excel CODE Function

Excel CODE function
Summary 

The Excel CODE function returns a numeric code for a given character.  For example, CODE("a") returns the code 97.

Purpose 
Get the code for a character
Return value 
A numeric code representing a character.
Syntax 
=CODE (text)
Arguments 
  • text - The text for which you want a numeric code.
Version 
Usage notes 

The CODE function returns a numeric code for a given character. For example, CODE("a") returns the code 97:

=CODE("a") // returns 97

With the character "a" in cell A1, the formula below returns the same result:

=CODE(A1) // returns 97

The CODE function takes a single argument, text, which is normally a text value. If text contains more than one character, the CODE function returns a numeric code for the first character:

=CODE("A") // returns 65
=CODE("Apple") // returns 65

The CODE function will handle numeric input for the numbers 0-9:

=CODE(1) // returns 49

Generally speaking, the number returned by CODE is the code for a character in ASCII decimal notation. The CODE function was designed to operate in an ASCII/ANSI world, and only understands how to map characters that correspond to numbers 0-255. For extended character support on modern Unicode systems, see the UNICODE function.

Reverse CODE

To get a character for a given numeric code, you can use the CHAR function:

=CHAR(65) // returns "A"

CHAR performs the reverse of CODE, taking a numeric code and returning the corresponding character.

Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.