The CODE function in Excel returns a numeric code for the first character in a text string. This numeric code is based on the character set used by your computer, which is often the ASCII character set in Windows.
Syntax
excelCODE(text)
text: The text string for which you want the numeric code of the first character.
Example
Suppose you want to find the ASCII code of the first character in a string.
- Basic Usage:
- Formula:
=CODE("A") - Result:
65 - Explanation: The ASCII code for "A" is 65.
- Formula:
- Another Example:
- Formula:
=CODE("Excel") - Result:
69 - Explanation: The ASCII code for "E" is 69.
- Formula:
Practical Example
Imagine you have a list of characters in column A, and you want to find their corresponding ASCII codes in column B.
Enter the following characters in cells A1 to A3:
- A1:
A - A2:
b - A3:
3
- A1:
In cell B1, enter the formula:
excel=CODE(A1)Drag the fill handle from B1 to B3 to apply the formula to the other cells.
The results will be:
- B1:
65(ASCII code for "A") - B2:
98(ASCII code for "b") - B3:
51(ASCII code for "3")
Step-by-Step Example
Input Data:
- In cell A1, enter:
Hello - In cell A2, enter:
World - In cell A3, enter:
123
- In cell A1, enter:
Use the CODE Function:
- In cell B1, enter the formula:excel
=CODE(A1) - In cell B2, enter the formula:excel
=CODE(A2) - In cell B3, enter the formula:excel
=CODE(A3)
- In cell B1, enter the formula:
Results:
- B1:
72(ASCII code for "H") - B2:
87(ASCII code for "W") - B3:
49(ASCII code for "1")
- B1:
Example with Special Characters
If you want to find the ASCII code of a special character:
- In cell A1, enter:
! - In cell B1, enter the formula:excel
=CODE(A1) - The result in cell B1 will be:
33(ASCII code for "!")
These examples illustrate how the CODE function can be used to find the ASCII codes of characters in Excel, allowing for a variety of text analysis and processing tasks.

No comments:
Post a Comment