How to Use Excel's Code Function

By eHow Computers Editor

Rate: (1 Ratings)

Excel's Code function determines the numeric representation for the first character in the specified text string. This value is determined by the character set being used. This will be the Macintosh character set for Macintosh computers and the ANSI characters for Windows computers. The following steps will show how to use Excel's Code function.

Instructions

Difficulty: Moderate

Step1
Learn the syntax for Code. It is Code(text_string) where text_string is the text value. Code will return the code for the first character in text_string.
Step2
Use a cell reference, named range or text string as valid input for the Code function. The Code function will return #Value! if the argument can't be resolved to a text value.
Step3
Look at the following simple examples for uses of Code: Code ("A")=65, Code ("B")=66, Code ("C")=67 and so on. These results assume that you are running Excel on a Windows computer.
Step4
Examine more complex uses of the Code function.

Code ("Alphabet") = 65. Note that only the code for the first character is returned.
Code (-1) = 45. The input -1 is implicitly converted to the text "-1" and the ASCII code for "-" (the hyphen) is 45.
Code (CHAR(23)) = 23. This use shows that the Code function is the inverse of Char.
Code ("") = #Value!. The empty text cannot be resolved to a text value and therefore returns the #Value! error code.
Step5
Study the ASCII character values to check the results of Code. Note that character values 0 to 31 are unprintable and will be represented by a small square in Windows.

Post a Comment

POST A COMMENT

Request a New How-To Article

Looking for more How To information? Chances are there’s an eHow member who knows how to do what you’re looking to do. Submit an article request now!

eHow Article:  How to Use Excel's Code Function

eHow Computers Editor

eHow Computers Editor

Category: Computers

Articles: See my other articles

Related Ads