Purpose
Return value
Syntax
=CHAR(number)
- number - A number between 1 and 255.
How to use
The CHAR function returns a character when given a valid character code. Use the CHAR to translate ASCII code page numbers into actual characters. For example:
=CHAR(65) // returns "A"
=CHAR(97) // returns "a"
the CHAR function takes just one argument, number, which must be an integer between 0-255. The result from CHAR is a text value.
The CHAR function was designed to operate in an ASCII/ANSI world and only understands numbers 0-255. For extended character support on modern Unicode systems, see the UNICHAR function.
CHAR can be useful when you want to specify characters in formulas or functions that are awkward or impossible to type directly. For example, you can use CHAR(10) to add a line break in a formula like this:
="line 1"&CHAR(10)&"Line 2" // add line break
Notes: Text wrap must be enabled to see the line break take effect. Older versions of Excel on the Mac use character 13 for a line break.
Reverse CHAR
To get the numeric code for a character, you can use the CODE function:
=CODE("A") // returns 65
CODE performs the reverse of CHAR, taking a character as text and returning a number.
ASCII and ANSI
The numbers returned by the CHAR function come from ASCII. ASCII stands for "American Standard Code for Information Interchange" and is a 7-bit character set that contains characters from 0 to 127.
The original ASCII specification encodes 128 characters into numbers. These include the numbers 0 to 9, lowercase a-z, uppercase A-Z, and punctuation. The first 32 characters are non-printing "control codes", most of which are no longer used, with the exception of the carriage return (13), line feed (10), and tab (9).
ANSI (American National Standards Institute) is a generic term for 8-bit character sets, the default in Windows 95 and Windows NT. ANSI includes the same ASCII codes 0-127, and adds an additional 128 characters (128-255) to handle special characters which can change based on the language being represented.
Notes
- If number is out of range, CHAR returns #VALUE!
- If number is not numeric, CHAR returns #VALUE!