CODE Excel Function

Publication Date :

Blog Author :

Download FREE CODE Function Excel Template and Follow Along!
CODE Function Excel Template.xlsx

Table Of Contents

arrow

CODE Function in Excel

The CODE function in Excel is used to find out the character's code in the string. It finds out the code for the first character only, so if we use this formula as =CODE("Anand") and =CODE("An"), we will get the same result as 65 as the code for character A is 65.

For example, suppose we have data with characters such as A, a, 0, and -11. In this case, the CODE function under the Excel Text functions will return the result as ANSII code for A, a, and 0. Whereas, for -11, it will provide the  ANSII code for - and ignore 11.

Syntax

code formula

Parameters

  • text: The text parameter is only a mandatory parameter of the CODE function. This parameter could be a single character, a string, or function that returns a text.

How to Use the CODE Function in Excel? (with Examples)

In this section, we will understand the use of the CODE function and look at a few examples with the help of actual data.

Example #1

CODE Function Example 1

As we can see in the output section, the CODE function returns the ASCII value of the corresponding characters written in the first column. For example, the ASCII value of "A" is 65, and "a" is 97. We can easily verify the ASCII values of every keyboard character from the internet.

Things to Remember

  1. The primary purpose of the CODE function is to return the ASCII code of a character of the first character in any cell.
  2. The CODE function is not popular among the Excel community. Still, we should be aware of it as an Excel expert, as we might find it handy in VBA Coding.
  3. It was first introduced in Excel 2000 and is available in all subsequent versions of Excel.
  4. The parameter "text" in the CODE function is mandatory. If left blank, the function will return a #VALUE! Error, which we can quickly resolve by providing an actual character or string as a parameter to the function.
  5. The return type of the CODE function is a numeric value.
  6. It is the inverse of the CHAR function in Excel.  The CHAR function returns the corresponding character from a numeric ASCII value.
  7. We might observe a different output than the one shown in our examples on a Mac OS because Mac OS uses the Macintosh character set while Windows uses the ANSI character set.