CODE function
a numeric code for the first character in a text string.
Text
Where can you use it?
Data preparation and reporting teams. Use this group to clean, split or reformat IDs, names and descriptions before using them in reports.
Scenario in the workbook
Read the numeric code of the first character. Later characters do not affect the result.
A worked example from the workbook
| Row | A |
|---|---|
| 6 | Input |
| 7 | A |
| 8 | B |
| 9 | Z |
Record 1
=CODE(A7)Expected result65
See the inputs and instructions for all 3 examplesCopyable formulas
English Excel · en-US
=CODE("A")Turkish Excel · tr-TR
=KOD("A")Expected result
65
Worked examples
Read the numeric code of the first character. Later characters do not affect the result.
Open the English sheet. Inputs begin at A6. F7:F9 show the live results and G7:G9 show the original results for comparison.
| Row | A |
|---|---|
| 6 | Input |
| 7 | A |
| 8 | B |
| 9 | Z |
| Case | Formula | Expected result |
|---|---|---|
| Record 1 | =CODE(A7) |
65 |
| Record 2 | =CODE(A8) |
66 |
| Record 3 | =CODE(A9) |
90 |