Function to convert column number to letter?

mezamorphic picture mezamorphic · Oct 9, 2012 · Viewed 420.5k times · Source

Does anyone have an Excel VBA function which can return the column letter(s) from a number?

For example, entering 100 should return CV.

Answer

brettdj picture brettdj · Oct 9, 2012

This function returns the column letter for a given column number.

Function Col_Letter(lngCol As Long) As String
    Dim vArr
    vArr = Split(Cells(1, lngCol).Address(True, False), "$")
    Col_Letter = vArr(0)
End Function

testing code for column 100

Sub Test()
    MsgBox Col_Letter(100)
End Sub