Is there a more pythonic way of converting excel-style columns to numbers (starting with 1)?
Working code up to two letters:
After reading this, I decided to find a way to do it directly in Excel cells. It even accounts for columns after Z.
Just paste this formula into a cell of any row of any column and it will give you the corresponding number.
=IF(LEN(SUBSTITUTE(ADDRESS(ROW(),COLUMN(),4),ROW(),""))=2,
CODE(LEFT(SUBSTITUTE(ADDRESS(ROW(),COLUMN(),4),ROW(),""),1))-64*26)+
CODE(RIGHT(SUBSTITUTE(ADDRESS(ROW(),COLUMN(),4),ROW(),""),1)-64),
CODE(SUBSTITUTE(ADDRESS(ROW(),COLUMN(),4),ROW(),""))-64)
The theme here was to grab the letter of the column, get the Code()
of it and subtract 64, based on the fact that the ASCII character code for letter A
is 64.