CODE Function in Excel

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

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

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.

Example #2

In the above example, we have applied the CODE function on cells containing strings. So as we can see in the output column, the CODE function returns the ASCII value of the first character of the sentence.

Example #3

For example, 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 lowercase of the character passed as a parameter. Similarly, the UPPER function returns the uppercase of a character passed as a parameter.

Things to Remember

  • The primary purpose of the CODE function is to return the ASCII code of a character of the first character in any cell.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 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 task.read more.It was first introduced in Excel 2000 and is available in all subsequent versions of Excel.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.The return type of the CODE function is a numeric value.It is 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 A.read more.  The CHAR function returns the corresponding character from a numeric ASCII value.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.

CODE Function in Excel Video

This article is a guide to CODE in Excel. We discuss how to use the Excel CODE function and Excel examples, and downloadable Excel templates. You may also look at these useful functions in Excel: –

  • MAX Excel FunctionFREQUENCY FunctionTEXT Function in ExcelPROPER in Excel |ExamplesPivot Table Field Name Is Not Valid