Does anyone have an Excel VBA function which can return the column letter(s) from a number?
For example, entering 100 should return CV
.
Does anyone have an Excel VBA function which can return the column letter(s) from a number?
For example, entering 100 should return CV
.
Here, a simple function in Pascal (Delphi).
This formula will give the column based on a range (i.e., A1), where range is a single cell. If a multi-cell range is given it will return the top-left cell. Note, both cell references must be the same:
MID(CELL("address",A1),2,SEARCH("$",CELL("address",A1),2)-2)
How it works:
CELL("property","range") returns a specific value of the range depending on the property used. In this case the cell address. The address property returns a value $[col]$[row], i.e. A1 -> $A$1. The MID function parses out the column value between the $ symbols.
If you'd rather not use a range object:
what about just converting to the ascii number and using Chr() to convert back to a letter?
col_letter = Chr(Selection.Column + 96)
Here is a late answer, just for simplistic approach using
Int()
andIf
in case of 1-3 character columns: