Function to convert column number to letter?

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

    This will work regardless of what column inside your one code line for cell thats located in row X, in column Y:

    Mid(Cells(X,Y).Address, 2, instr(2,Cells(X,Y).Address,"$")-2)
    

    If you have a cell with unique defined name "Cellname":

    Mid(Cells(1,val(range("Cellname").Column)).Address, 2, instr(2,Cells(1,val(range("Cellname").Column)).Address,"$")-2)
    

提交回复
热议问题