Column letter to index

  • Thread starter Thread starter Radon
  • Start date Start date
R

Radon

How do I convert column letters to column index? I have a VBA routine that
reads cells that contains destination cells. For instance, cell C2 may have
the letter D, which indicats that column D is where the output should go.
 
In options you can set R1C1 reference style where the columns are numbered
instead of having alpha characters.

However, I am not certain that is what you are referring to because I am a
bit confused by your description of the problem. Could you post some of the
code so that we can see exactly what you are referring to.
 
Maybe...
'--
Sub MakeItNumeric()
Dim N As Long
N = Columns(Range("C2").Value).Column
MsgBox N
End Sub
--
Jim Cone
Portland, Oregon USA


"Radon" <[email protected]>
wrote in message
How do I convert column letters to column index? I have a VBA routine that
reads cells that contains destination cells. For instance, cell C2 may have
the letter D, which indicats that column D is where the output should go.
 
Hi,

In VBA code this will put Stuff cell D1 if the letter D is in C2 of the
active sheet.

Sub test()
Range([C2] & "1") = "Stuff"

End Sub
 
After reading, this thread, I arrived to this function to do that

Private Function Col(colLetter As String)
Col = Columns(colLetter).Column
End Function

Col("T") returns 20!
 
Back
Top