CODE()

Syntax. CODE(text)

Definition. This function returns the code of the first character in a string. The code corresponds to the character set used by your computer.

Arguments

  • text (required). The text from which the code for the first character is returned

Background. Sometimes it is useful to know the code of a character, such as a special character. CODE() is the counterpart of CHAR(), which returns the character for a code value.

Because the function returns the code value for the first character of the text, you need to use only a single-letter argument. CODE("Excel"), CODE("Ergonomics") and CODE("E") all return 69 for the capital letter E.

To return the code for the second or third character, use the MID() function. The formula

=CODE(MID("Excel",2,1)) ...

Get Microsoft® Excel® 2010 Formulas & Functions Inside Out now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.