Excel Column Letter to Number: How the A=1, Z=26, AA=27 System Really Works
Excel columns count in bijective base-26: A is 1, Z is 26, AA is 27, with no zero digit. Here is the math, a worked example, and why macros need it.
Excel Column Letter to Number: How the A=1, Z=26, AA=27 System Really Works
If you have ever written a spreadsheet macro, you have hit the wall: the library wants a column number, but the spec on your screen, the error message in your log, and your own brain all speak in letters. Column AB. Column CV. "The totals are in AZ." Translating between the two by hand is slow and it is where off-by-one bugs love to hide.
The conversion looks trivial until you try to do it in your head past column Z. Then the question that trips almost everyone shows up: if Z is 26, why is AA 27 and not 1? The answer is a small, elegant counting system, and once it clicks you will never miscount a column header again.
Columns Count in Bijective Base-26
Here is the one concrete fact that explains everything else: Excel, Google Sheets, and every spreadsheet I have used number their columns with bijective base-26. That means every digit position carries a value from 1 to 26, and there is no zero digit at all.
Ordinary base-26 would behave like the decimal numbers you know: it would have digits 0 through 25, and "10" in that system would mean 26. Spreadsheet columns do not work that way. There is no character that stands for zero, so you can never write a "leading zero" column. The letters run A through Z for the single-letter columns, and the moment you need a second character, the count simply continues — it does not reset to some AA-means-zero state.
That single design choice is why the jump from Z to AA is seamless. Z is the 26th and final single-letter column. The very next column over is AA, and because there is no zero to fill, AA picks up immediately at 27. AB is 28, AZ is 52, BA is 53, and so on. When you reach ZZ you are at 702, and the three-letter columns begin with AAA at 703. Excel itself stops at column XFD, which works out to 16384 — the rightmost column on a worksheet.
A Worked Example You Can Follow by Hand
Let me walk through the math, because seeing it once makes the whole thing obvious.
To turn letters into a number, treat each letter as a value from 1 (A) to 26 (Z), then accumulate left to right. Start at 0, and for each letter set total = total × 26 + letter_value.
Take AB:
- A is 1. Start:
0 × 26 + 1 = 1. - B is 2. Continue:
1 × 26 + 2 = 28.
So AB = 28. That matches the "AA is 27, AB is 28" run exactly.
Now the other direction, number to letters. You subtract 1, take the remainder modulo 26 for the rightmost letter, divide down, and repeat. Convert column 100:
- 100 − 1 = 99.
99 mod 26 = 21→ the 22nd letter (count 0 as A's neighbor: value 21 + 1 = 22) is V. Carryfloor(99 / 26) = 3. - 3 − 1 = 2.
2 mod 26 = 2→ value 2 + 1 = 3 → C. Carryfloor(2 / 26) = 0, so we stop.
Reading the letters in the order they were produced gives CV. So column 100 is CV — not something you would want to count out across a hundred headers, and exactly the kind of thing the Excel Column Converter does instantly, for one value or a whole pasted list.
Why Macro and API Authors Need This
The conversion matters most when a human-readable letter meets a programming interface that only understands integers.
In VBA, Cells(1, 703) refers to cell AAA1 — but the macro hands you the number 703, and you need "AAA" to build an A1-style formula string or to write a readable log line. In Google Apps Script the getRange(row, column) call is the same story: column is a 1-based integer, and your spec is written in letters. Python's openpyxl and pandas workflows hit it from both sides — you read a column legend that says "notes live in AZ" and you have to feed your loop the number 52.
There is one trap worth flagging here: Excel columns are 1-based (A is 1), but plenty of libraries and array indices are 0-based. The converter gives you the 1-based index that lines up with the column header you see in the app. If your API wants a 0-based value, subtract 1 after converting — AB becomes 28 for Excel, 27 for a 0-based array.
The Bijective System Is Not Unique to Spreadsheets
Once you recognize bijective base-26, you start spotting it in other places — spreadsheet column labels are essentially a number written in a positional system with an unusual digit set. If you enjoy this kind of radix puzzle, the same "what does this value look like in another base?" question comes up constantly in programming, and a general-purpose base converter is the tool for the standard radixes (binary, octal, hex). The difference is that those use a zero digit and spreadsheet columns deliberately do not, which is the whole reason AA lands on 27 instead of restarting the count.
A Faster Way Than Counting Headers
I will be honest about how I actually use this. I keep the converter open in a tab whenever I am scripting against a wide export. The other day an import failed with "bad value in column 100," and my CSV viewer only showed letters. Instead of dragging across the header row and miscounting somewhere in the eighties — which I have done, and then chased the wrong cell for ten minutes — I typed 100, read CV, jumped straight there, and fixed it. The batch panel earns its keep too: when a spec lists six columns by letter, I paste all six, one per line, and get the index list back in a single pass to drop into a loop.
If your input is the other way around — a real CSV file where you want to pull one column out by its letter or header name rather than convert an index — that is a different job, and the CSV column extractor is built for it. The column converter is for the pure letter-to-number arithmetic; the extractor operates on actual file rows.
The Short Version
Spreadsheet columns are bijective base-26: digits 1 through 26, no zero. That is why A is 1, Z is 26, and AA continues to 27 rather than resetting. To go letter-to-number, multiply the running total by 26 and add each letter's value (AB = 28). To go number-to-letter, subtract 1, take the modulo, and divide down (100 = CV). Remember that Excel is 1-based, so subtract 1 again if your code is 0-based. Do it by hand when you want to understand it, and let the tool do it when you just want the answer and zero off-by-one bugs.
Made by Toolora · Updated 2026-06-13