excelvbaexcel-udf

Function to convert column number to letter?


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

For example, entering 100 should return CV.


Solution

  • 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