CODE function

Returns a numeric code for the first character in a text string. The returned code corresponds to the character set used by your computer.


CODE (text)




The text for which you want the code of the first character.

Character set

Operating environment

Character set


Macintosh character set



To make the following example easier to understand, you can copy the data to a blank sheet and then enter the function underneath the data. Do not select the row or column headings (1, 2, 3... A, B, C...) when you copy the sample data to a blank sheet.

For mula

Description (Result)

=CODE ("A")

Displays the numeric code for A (65)

=CODE ("!")

Displays the numeric code for ! (33)

See also

CHAR function

List of all functions (by category)

Applies To: Excel for Mac 2011

Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language