Function to convert column number to letter?

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

    robertsd's code is elegant, yet to make it future-proof, change the declaration of n to type long

    In case you want a formula to avoid macro's, here is something that works up to column 702 inclusive

    =IF(A1>26,CHAR(INT((A1-1)/26)+64),"")&CHAR(MOD(A1-1,26)+65)
    

    where A1 is the cell containing the column number to be converted to letters.

提交回复
热议问题