Code:
Function ConvertToLetter(iCol As Integer) As String
Dim i, j As Integer
Dim sCol As String
Dim iAlpha As Integer
Dim iRemainder As Integer
iRemainder = Int(iCol Mod 26)
If iRemainder = 0 Then
iRemainder = 26
End If
sCol = Chr(iRemainder + 64)
If ((iCol - iRemainder) > 0) And (iCol > 26) Then
sCol = ConvertToLetter(Int((iCol - iRemainder) / 26)) & sCol
End If
ConvertToLetter = sCol
End Function
Function ConvertToInteger(cCol As String) As Integer
Dim iMid, i, j As Integer
cCol = Trim(cCol)
If Len(cCol) > 1 And Len(cCol) < 5 Then
iMid = 0
j = (Len(cCol) - 1)
For i = 1 To (Len(cCol) - 1)
iMid = iMid + (ConvertToInteger(Mid(cCol, i, 1)) * 26 ^ j)
j = j - 1
Next i
ConvertToInteger = iMid + (Asc(UCase(Right(cCol, 1))) - 64)
ElseIf Len(cCol) = 1 And Len(cCol) < 5 Then
ConvertToInteger = Asc(UCase(cCol)) - 64
Else
ConvertToInteger = 0
End If
End Function
Michael Libeson