Excel Column Letters to Numbers (and Back): The Maths and the Shortcuts
Why column AA is 27 and XFD is 16,384, how to convert by hand or with a formula, and what R1C1 references and range sizes mean in Excel and Sheets.
%3A%20The%20Maths%20and%20the%20Shortcuts&c=%234338ca&k=developer)
Spreadsheets name their columns with letters, but almost everything else counts with numbers. A script that reads an exported CSV wants the index of a field, an API returns column 37, and a colleague says the totals are in column AK. Converting between the two is easy once you see the pattern, and there are quick ways to do it without counting on your fingers.
The pattern: base 26 without a zero
Column letters behave like a number system with 26 digits, A to Z, worth 1 to 26. There is no zero digit, which is why the usual base conversion tricks give the wrong answer. After Z (26) comes AA (27), after AZ (52) comes BA (53), after ZZ (702) comes AAA (703). Current Excel stops at XFD, column 16,384.
Letters to a number. Go left to right. Start at zero; for each letter, multiply the total by 26 and add the letter's position. For AB: 0 × 26 + 1 = 1, then 1 × 26 + 2 = 28. For XFD: X gives 24, then 24 × 26 + 6 = 630, then 630 × 26 + 4 = 16,384.
A number to letters. Subtract one, take the remainder after dividing by 26 to get the last letter (0 is A, 25 is Z), divide by 26, and repeat. For 28: subtract one to get 27; 27 divided by 26 is 1 remainder 1, and remainder 1 is B. Carry the 1, subtract one again to get 0, whose remainder 0 is A. Reading the letters from last to first gives AB.
Doing it inside the spreadsheet
You do not always need a separate tool. In Excel and LibreOffice, the formula SUBSTITUTE(ADDRESS(1,A2,4),"1","") turns a column number in A2 into letters, because ADDRESS returns a reference like AB1 and the formula removes the row. COLUMN(INDIRECT(A2&"1")) does the reverse, turning letters in A2 into a number. Google Sheets can use REGEXREPLACE to strip the digits instead.
A1 and R1C1 references
The familiar A1 style names a cell by column letters and row number. Excel also has R1C1 style, which names cells by numbers: R3C2 is row 3, column 2, the same as $B$3. Square brackets make the reference relative to the cell containing the formula, so R[-1]C[2] means one row up and two columns to the right. R1C1 style is useful in VBA and in formula auditing, because a formula copied down a column reads the same in every row.
The dollar signs in A1 style decide what moves when you copy a formula. $A$1 never moves, A$1 keeps its row, $A1 keeps its column, and A1 moves both ways. The F4 key in Excel cycles through these four forms.
Using the converter
The Excel Column Letter and Number Converter does all of this in one place.
- Choose your program. Excel 2007 and later, Excel 97 to 2003, LibreOffice Calc or Google Sheets, so warnings use the right grid size.
- Convert single values. Type a number to get letters, or letters to get a number. Buttons step one column up or down.
- Work with references. Set the cell that holds the formula, then convert A1 to R1C1 and back, cycle the dollar signs like F4, and see where a reference moves when the formula is copied down and across.
- Size a range. Type B2:H101, a whole column such as B:D, a whole row range such as 3:7, or a reference with a sheet name, and read the rows, columns and cell count.
- Convert a list. Paste many values, one per line, and download the results as CSV or copy them as two columns.
- Print a table. The reference table lists letters and numbers for any range of columns, up to 2,000 at a time.
Grid limits worth knowing
Excel 2007 and later has 16,384 columns and 1,048,576 rows. The old .xls format stops at column IV (256) and row 65,536, which is why very wide exports sometimes lose columns when saved in the old format. LibreOffice Calc matches modern Excel since version 7.4. Google Sheets allows columns up to ZZZ, 18,278 of them, but caps a whole spreadsheet at 10 million cells, so a very wide sheet has fewer rows available.
A tip for programmers
Many libraries count columns from zero, while spreadsheets count from one. When a script writes to column index 27 and the data lands in AB instead of AA, an off-by-one between those systems is the usual cause. Convert with one-based numbers, as the spreadsheet does, and add or subtract one only at the boundary with your code.



