VBA Convert Column Number to Letter

As you already know, rows in Excel are labeled with numbers, so it’s easy to get to that row by specifying a number. But it’s not that easy to go, for example, to the 121st column because it’s labeled by one to three letters, so the first column is A and the last (16,384) is XFD.

In order to know, what label has the 121st column, you have to convert 121 to a character label. You can achieve this by using an Excel formula.

This formula will take the numerical value from A2 and returns it as a column label. Let’s autofill this formula for the rest of the cells.

The formula works, but it’s quite complicated. Let’s create a function that we can call from inside the worksheet, which takes only one parameter.

This VBA function gets one parameter, which indicated the column number, and returns the label from A(1) to XFD(16,384). If the number is larger, it returns False.

As you can see, the VBA function also works.

Tomasz Decker is an Excel specialist, skilled in data analysis and financial modeling.

Posted in vba