Function to convert column number to letter?

后端 未结 28 1990
灰色年华
灰色年华 2020-11-22 07:04

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

For example, entering 100 should return CV.

28条回答
  •  再見小時候
    2020-11-22 07:57

    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
    

提交回复
热议问题