Function to convert column number to letter?

后端 未结 28 1544
灰色年华
灰色年华 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:54

    This is available through using a formula:

    =SUBSTITUTE(ADDRESS(1,COLUMN(),4),"1","")
    

    and so also can be written as a VBA function as requested:

    Function ColName(colNum As Integer) As String
        ColName = Split(Worksheets(1).Cells(1, colNum).Address, "$")(1)
    End Function
    

提交回复
热议问题