Created
June 28, 2011 17:47
-
-
Save umq/1051698 to your computer and use it in GitHub Desktop.
Microsoft Office Excel column number to name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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