A few days I wrote a post about how to convert an cell address into coordinates (column number, and row number). I am working a quick Python script for work to import CSV data into a DB. In order to allow the user the ability to enter either the column number or the column name I used the following function to convert column names into number:
def colNameToNum(name): pow = 1 colNum = 0 for letter in name[::-1]: colNum += (int(letter, 36) -9) * pow pow *= 26 return colNum
As you can see, all you have to do is pass it the name of the column (letters) and the correspond column number will be returned. Have fun!