How to convert a letter to its position in the alphabet in Excel
Formula (Excel and Google Sheets)
=CODE(UPPER(A2))-64Use the character code: =CODE(UPPER(A2))-64 returns 1 for A, 2 for B, up to 26 for Z.
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Excel 2021, 2024 and Microsoft 365
- Google Sheets
- Same formula
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
How it works
CODE returns the character code of the first character: capital A is 65, B is 66, up to Z at 90. Subtracting 64 maps them to 1 to 26. UPPER first makes lowercase letters, which have codes 97 to 122, use the same numbers.
In Google Sheets
The same formula works in Google Sheets: =CODE(UPPER(A2))-64. We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =SEARCH(A2,"abcdefghijklmnopqrstuvwxyz") | 1, 3, 13… | Finds the letter in the alphabet written out. SEARCH ignores case, so no UPPER is needed. |
| =MATCH(UPPER(A2),CHAR(SEQUENCE(26,1,65)),0) | 1, 3, 13… | Excel 365: matches the letter against a generated list A to Z. |
Common mistakes
- CODE only reads the first character: "Apple" returns 1.
- Digits and symbols give meaningless results, like 0 for "@". Check with
AND(CODE(UPPER(A2))>=65,CODE(UPPER(A2))<=90)first.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Convert a letter to its position in the alphabet
B2, return the letter's position in the alphabet (A = 1, Z = 26), whatever its case, and fill down to B6.Questions
How do I turn a number back into a letter?
Add 64 and use CHAR: =CHAR(64+B2) gives C for 3.
How do I get the column number of a column letter like "AB"?
Use =COLUMN(INDIRECT(A2&"1")).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.