## 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)``
• text - The text for which you want a numeric code.

## How to use

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.

Author

### Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.