Column letter to index

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.
 
O

OssieMac

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.
 
J

Jim Cone

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.
 
S

Shane Devenshire

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
 
Joined
Feb 24, 2013
Messages
1
Reaction score
0
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top