Function converts a Letter to a Number (for instance: column AZ would = 52):   Return to List

Private Function ConvLtrToNum(ByVal LtrIn As String) As Integer
Dim TempChar As String
Dim TempNum As Integer
Dim NumArray() As Integer
TempChar = ""
TempNum = 0
LtrIn = UCase(LtrIn)
For i = 1 To Len(LtrIn)
    NumString = ""
    ' Change Ltr to Number Indicating Place in Alphabet from 01 to 26
    TempChar = Mid(LtrIn, i, 1)
    ReDim Preserve NumArray(i)
    NumArray(i) = Asc(TempChar) - 64
Next
' Our Most Significant Digits Occur to the Left
HighPower = UBound(NumArray()) - 1
' Convert the Number Array using Powers of 26
For i = 1 To UBound(NumArray())
    TempNum = TempNum + (NumArray(i) * (26 ^ HighPower))
    HighPower = HighPower - 1
Next
ConvLtrToNum = TempNum
End Function

See also:
Accessing Particular Cells in Worksheet
Column Number or Letter of selected cell
Convert Column Number to Letter function
Creating and Sizing Cell Comments
Delete Cell Contents without deleting cell
Determining Last Cells (column & row) with Data
Drop-Down Cell Values (restricting User)
Fill Empty Cells of Selected Area with Data Above Cell
Inserting a Formula into the Active Cell
Moving down one cell (changing active cell)
Moving Right 1 Cell
Pasting (previously copied) Cells
Row number of Selected Cell
Selecting ALL the Cells in a Worksheet
Selecting Non-Adjacent Cells in Worksheet
Setting Current Cell's Value



Note to Webmaster