CODE Excel Function

CODE Function in Excel

Code Function in excel is used to find out the code of the character 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.


code formula


  • text: The text parameter is only and a mandatory parameter of the CODE Function. This parameter could be one single character, a string, or any function which returns a text as a result.

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

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


You can download this CODE Function Excel Template here – CODE Function Excel Template

Example #1

CODE Function Example 1

As you can clearly observe in the output section, the CODE function is returning the ASCII value of corresponding Characters written in the first column. The ASCII value of “A” is 65, and “a” is 97. You can easily verify the ASCII values of every character of your keyboard form the Internet.

Example #2

Example 2

In the above example, we have applied the CODE function on cells containing strings, so as you can see in the output column, the CODE Function is returning the ASCII value of the first character of the sentence.

Example #3

Example 3

For example, three, we have used another two functions, LOWER and UPPER, to use their return value as a parameter of the CODE function. The LOWER function returns the lower case of the character passed as a parameter; similarly, UPPER returns the upper case of a character passed as a parameter.

Things to Remember

  1. The main 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 that popular among the excel community, but as an excel expert, you should be aware of this function, as you might find it handy in VBA CodingVBA CodingVBA code refers to a set of instructions written by the user in the Visual Basic Applications programming language on a Visual Basic Editor (VBE) to perform a specific more.
  3. It was first introduced in Excel 2000 and is available in all subsequent versions of excel.
  4. The parameter “text” in CODE Function is mandatory, and if it is left blank, the function will return a #VALUE error, which can easily be resolved by providing a proper character or string as a parameter to the function.
  5. The return type of CODE Function is a numeric value.
  6. It is actually the inverse of the CHAR function in excelCHAR Function In ExcelThe character function in Excel, also known as the char function, identifies the character based on the number or integer accepted by the computer language. For example, the number for character "A" is 65, so if we use =char(65), we get more. The CHAR function returns the corresponding character from a numeric ASCII value.
  7. You 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 use the ANSI character set.

CODE Function in Excel Video


Recommended Articles

This has been a guide to CODE in Excel. Here we discuss the CODE Formula in excel and how to use the CODE function along with excel example and downloadable excel templates. You may also look at these useful functions in excel –

  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion