View Single Post
  #22   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default VBA range selection question

If anyone is still reading this thread, here is the generalization of the
function I asked you (Joe) to time test; it will work with XL2007 and XL2010
(and beyond if Microsoft decides to add more columns in the future) as well
as with prior versions...

Function GetColNum(myColumn As String) As Long
Dim X As Long, Multiplier As Long, B() As Byte
B = UCase(myColumn)
Multiplier = 1
For X = UBound(B) - 1 To LBound(B) Step -2
GetColNum = GetColNum + Multiplier * (B(X) - 64)
Multiplier = 26 * Multiplier
Next
End Function

I believe this function (as well as the one I posted earlier for XL2003 and
before) will execute about as fast as is possible due to the use of Byte
arrays and, as such, I expect it to execute (noticeably?) faster than the
String-based version that you (Joe) posted.

Rick Rothstein (MVP - Excel)