Last active
May 13, 2020 20:22
-
-
Save DavidMetcalfe/772a241283c7af819ecadbaf6bceae38 to your computer and use it in GitHub Desktop.
Convert between column numbers and column letters in Excel VBA
This file contains hidden or 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 columnLetterToNumber(letter) As Long | |
' Convert a given column letter into the corresponding column number. | |
columnLetterToNumber = Range(letter & 1).Column | |
End Function |
This file contains hidden or 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 columnNumberToLetter(number) As String | |
' Convert a given column number into the corresponding column letter. | |
columnNumberToLetter = Split(Cells(1, number).address, "$")(1) | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment