Problems can arise when converting the character codes from one system to another system. These problems result in garbled data. To correct this, a universal character set known as Unicode system was developed during the late 1980s that gives the characters used in computer systems a unique character code.

The information is this article applies to Excel 2019, Excel 2016, Excel 2013, Excel 2010, Excel 2019 for Mac, Excel 2016 for Mac, Excel for Mac 2011, and Excel Online.

Universal Character Set

There are 255 different character codes or code points in the Windows ANSI code page while the Unicode system is designed to hold over one million code points. For the sake of compatibility, the first 255 code points of the newer Unicode system match those of the ANSI system for western language characters and numbers.

For these standard characters, the codes are programmed into the computer so that typing a letter on the keyboard enters the code for the letter into the application being used.

Non-standard characters and symbols, such as the copyright symbol or accented characters used in various languages, are entered into an application by typing the ANSI code or Unicode number for the character in the desired location.

Excel CHAR and CODE Functions

Excel has a number of functions that work with these numbers. CHAR and CODE work in all versions of Excel. UNICHAR and UNICODE were introduced in Excel 2013.

The CHAR and UNICHAR functions return the character for a given code. The CODE and UNICODE functions do the opposite and provide the code for a given character. As shown in the image above:

  • The result for =CHAR (169) is the copyright symbol ©.The result for =CODE(©) is 169.

If the two functions are nested together in the form of

=CODE(CHAR(169))

the output for the formula is 169 since the two functions do the opposite job of the other.

The CHAR and UNICHAR Functions Syntax and Arguments

A function’s syntax refers to the layout of the function and includes the function’s name, brackets, and arguments.

The syntax for the CHAR function is:

=CHAR(Number)

The syntax for the UNICHAR function is:

=UNICHAR(Number)

In these functions, Number (which is required) is a number between 1 and 255 that is associated with the character you want.

  • The Number argument can be the number entered directly into the function or a cell reference to the location of the number on a worksheet.
  • If the Number argument is not an integer between 1 and 255, the CHAR function returns the #VALUE! error value, as shown in row 4 in the image above.
  • For code numbers greater than 255, use the UNICHAR function.
  • If a Number argument of zero (0) is entered, the CHAR and UNICHAR functions return the #VALUE! error value, as shown in row 2 in the image above.

Enter the CHAR and UNICHAR Functions

Options for entering either function include typing the function in manually, such as

=CHAR(65)

or

=UNICHAR(A7)

The function and the Number argument can also be entered in the functions’ dialog box.

In Excel Online, you’ll manually enter the function. In desktop versions of Excel, use the dialog box.

Follow these steps to enter the CHAR function into cell B3:

  • Select cell B3 to make it the active cell.
  • Select Formulas.
  • Choose Text to open the function drop-down list.
  • Select CHAR in the list to bring up the function’s dialog box.
  • In the dialog box, select the Number line.
  • Select cell A3 in the worksheet to enter that cell reference into the dialog box.
  • Select OK to complete the function and close the dialog box.

The exclamation mark character appears in cell B3 because its ANSI character code is 33.

When you select cell E2, the complete function =CHAR(A3) appears in the formula bar above the worksheet.

CHAR and UNICHAR Function Uses

The CHAR and UNICHAR functions translate code page numbers into characters for files created on other types of computers. For example, the CHAR function can remove unwanted characters that appear with imported data.

These functions can be used in conjunction with other Excel functions, such as TRIM and SUBSTITUTE, in formulas designed to remove unwanted characters from a worksheet.

The CODE and UNICODE Functions Syntax and Arguments

The syntax for the CODE function is:

=CODE(Text)

The syntax for the UNICODE function is:

=UNICODE(Text)

In these functions, Text (which is required) is the character for which you want to find the ANSI code number.

The Text argument can be a single character surrounded by double quotation marks ( " " ) that is entered directly into the function or a cell reference to the location of the character in a worksheet, as shown in rows 4 and 9 in the image above.

If the text argument is left empty, the CODE function returns the #VALUE! error value, as shown in row 2 in the image above.

The CODE function only displays the character code for a single character. If the text argument contains more than one character (such as the word Excel shown in rows 7 and 8 in the image above), only the code for the first character is displayed. In this case, it is the number 69 which is the character code for the uppercase letter E.

Uppercase vs. Lowercase Letters

Uppercase or capital letters on the keyboard have different character codes than the corresponding lowercase or small letters.

For example, the UNICODE/ANSI code number for the uppercase “A” is 65 while the lowercase “a” UNICODE/ANSI code number is 97, as shown in rows 4 and 5 in the image above.

Enter the CODE and UNICODE Functions

Options for entering either function include typing the function in a cell, such as:

=CODE(65)

=UNICODE(A6)

The function and the Text argument can also be entered in the functions’ dialog box.

Follow these steps to enter the CODE function into cell B3:

  • Select cell B3 to make it the active cell.Select Formulas.Choose Text to open the function drop-down list.Select CODE in the list to bring up the function’s dialog box.In the dialog box, select the Text line.Select cell A3 in the worksheet to enter that cell reference into the dialog box.Select OK to complete the function and close the dialog box.

The number 64 appears in cell B3. This is the character code for the ampersand ( & ) character.

When you select cell B3, the complete function =CODE (A3) appears in the formula bar above the worksheet.

Get the Latest Tech News Delivered Every Day