Microsoft Office Tutorials and References
In Depth Information
Text Functions
The CODE and CHAR functions work only with ANSI strings. These functions do not
work with double-byte Unicode strings.
The CODE function
Excel’s CODE function returns the ANSI character code for its argument. The formula that follows
returns 65, the character code for uppercase A:
=CODE(“A”)
If the argument for CODE consists of more than one character, the function uses only the first
character. Therefore, this formula also returns 65:
=CODE(“Abbey Road”)
The CHAR function
The CHAR function is essentially the opposite of the CODE function. Its argument is a value
between 1 and 255; the function returns the corresponding character. The following formula, for
example, returns the letter A:
=CHAR(65)
To demonstrate the opposing nature of the CODE and CHAR functions, try entering this formula:
=CHAR(CODE(“A”))
This formula (illustrative rather than useful) returns the letter A. First, it converts the character to
its code value (65) and then it converts this code back to the corresponding character.
Assume that cell A1 contains the letter A (uppercase). The following formula returns the letter a
(lowercase):
=CHAR(CODE(A1)+32)
This formula takes advantage of the fact that the alphabetic characters all appear in alphabetical
order within the character set, and the lowercase letters follow the uppercase letters (with a few
other characters tossed in between). Each lowercase letter lies exactly 32 character positions
higher than its corresponding uppercase letter.
 
Search JabSto ::




Custom Search