Skip to content

Instantly share code, notes, and snippets.

@umq
Created June 28, 2011 17:47
Show Gist options
  • Save umq/1051698 to your computer and use it in GitHub Desktop.
Save umq/1051698 to your computer and use it in GitHub Desktop.
Microsoft Office Excel column number to name
Function ColNum2Name(Col As Long) As String
Dim C As Integer
Col = Col - 1 ' 1 -> A, 26 -> Z, 27 -> AA
If (Col >= 0) Then
While (Col >= 0)
C = Col Mod 26
Col = Col \ 26 - 1
ColNum2Name = Chr$(Asc("A") + C) + ColNum2Name
Wend
Else
ColNum2Name = "##ERR!##"
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment