=CODE(text)One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.
Need more than a single CODE formula? Try our free AI for Excel — it reads your entire spreadsheet, answers questions in plain English, and builds charts and analysis in the same chat.
text:
The text string for which you want to find the numeric code of the first character. This can be a text string, a cell reference containing text, or a formula that returns text.
The CODE function in Excel is a simple yet useful tool that returns the numeric code corresponding to the first character in a text string. This function can be particularly helpful when you need to analyze or manipulate text data based on character codes, such as identifying specific characters or performing comparisons.
In simpler terms, the CODE function helps you understand the underlying numeric representation of characters, making it easier to work with text data.
Imagine you have a list of product codes in an Excel spreadsheet, and you want to find out the numeric code for the first character of each product code.
| Product Code |
|---|
| A123 |
| B456 |
| C789 |
| D012 |
| E345 |
You want to determine the numeric code for the first character of each product code.
To find the numeric code for the first character of the product code in cell A2, you would use the CODE formula as follows:
=CODE(LEFT(A2, 1))When you apply the formula to each product code, you will get the following results:
| Product Code | Numeric Code |
|---|---|
| A123 | 65 |
| B456 | 66 |
| C789 | 67 |
| D012 | 68 |
| E345 | 69 |
Here, the numeric codes correspond to the ASCII values of the first characters: A (65), B (66), C (67), D (68), and E (69).
The CODE function is particularly useful when you need to analyze text data based on character codes, perform comparisons, or convert characters to their numeric representations. It allows you to gain insights into the structure of your text data and can be used in various text manipulation tasks.
Understanding how to use the CODE function can enhance your ability to work with text data in Excel, enabling you to perform more advanced data analysis and manipulation tasks.
Happy coding!
You have a list of product codes in Column A and you want to determine the ASCII value of the first character of each product code. By using the CODE function, you can easily extract this information for analysis. This allows for quick identification of product categories based on their initial character, aiding in inventory management and product classification without the need for complex programming or additional tools.
Beyond the CODE function: Better Analyst is a full Excel AI that goes well past individual formulas. Upload any spreadsheet and ask questions in plain English — you'll get formulas, data analysis, and charts back in seconds. It's a free AI Excel assistant that works with any .xlsx, .xls, or .csv file — no plugins, no Microsoft 365 required.
Don't have a spreadsheet yet? Use our free AI spreadsheet generator to turn a text prompt into a downloadable Excel file — a full AI Excel sheet maker that builds headers, columns, and formulas from your description.
Create a free account for formula help, explanations, and spreadsheet analysis. Usage limits depend on your plan.
Browse our complete library of Excel formula guides
Compare your options
Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.
AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.