Function to convert column number to letter?

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

    this is only for REFEDIT ... generaly use uphere code shortly version... easy to be read and understood / it use poz of $

    Private Sub RefEdit1_Change()
    
        Me.Label1.Caption = NOtoLETTER(RefEdit1.Value) ' you may assign to a variable  var=....'
    
    End Sub
    
    Function NOtoLETTER(REFedit)
    
        Dim First As Long, Second As Long
    
        First = InStr(REFedit, "$")                 'first poz of $
        Second = InStr(First + 1, REFedit, "$")     'second poz of $
    
        NOtoLETTER = Mid(REFedit, First + 1, Second - First - 1)   'extract COLUMN LETTER
    
    End Function
    

提交回复
热议问题