Excel Char Function

Character Encoding

The character encoding used by your computer depends on the operating system used.

Windows uses the ANSI character set, whereas Macintosh uses the Macintosh character set.

Therefore, the characters returned by the Excel Char Function for specific number codes may be different on different operating environments.

Basic Description

The Excel Char function returns the character relating to a supplied character set number (from 1 to 255).

Note that the character set may vary across different operating systems and so, for a specific number, the Char function may return different results on different computers.

The syntax of the Char function is:

CHAR( number )

Where the number argument is an integer from 1 to 255.

Char Function Examples

Example 1

The following spreadsheet provides examples of the Excel Char function, used to return the character associated with four different character set numbers.

Note that these results are from the Ansi character set (used on the Windows operating system).

1 =CHAR( 65 )
2 =CHAR( 97 )
363=CHAR( A3 )
451=CHAR( A4 )
1 A
2 a

Example 2

One use of the CHAR function is when inserting line breaks into text. This is shown in the example below (Note that, in the Ansi character set, the line break is associated to the character set number 10):

1="This line contains a" & CHAR( 10 ) & "line break"
1This line contains a
line break

Note that, in the example above, in order to display the result with the line break, you will need to ensure that the cell text wrapping is enabled.

Enabling Text Wrapping

The easiest way to enable text wrapping in a cell is to use the Wrap Text button, which is located in the 'Alignment' group of the Home tab of the Excel ribbon (see below).

Excel Wrap Text Button

Alternatively, if you have an older version of Excel, that does not have the ribbon, you can wrap text in a cell as follows:

  • Right click on the cell and select Format Cells ...
  • Select the Alignment tab of the dialog box that pops up;
  • Check the box next to the Wrap text option and click OK.

Further information and examples of the Excel Char Function are provided on the Microsoft Office website.

Char Function Error

If you get an error from the Excel Char function, this is likely to be the #VALUE! error:

Common Error
#VALUE!-Occurs if the supplied number argument is not recognised as a numeric value or is a number outside of the permitted range 1 to 255.