Function to convert column number to letter?

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

    Here is a simple one liner that can be used.

    ColumnLetter = Mid(Cells(Row, LastColA).Address, 2, 1)
    

    It will only work for a 1 letter column designation, but it is nice for simple cases. If you need it to work for exclusively 2 letter designations, then you could use the following:

    ColumnLetter = Mid(Cells(Row, LastColA).Address, 2, 2)
    

提交回复
热议问题