Hot to Get a Column Number from a column letter

  • Thread starter Thread starter TWR
  • Start date Start date
T

TWR

Is there an easy way to get the column number from the column letter in Excel
2002 VBA, similar to the worksheet function =COLUMN(B:B) which equal 2?
 
hi
one way
Range("B2").Value = Range("D1").Column
which would produce the number 4 in cell B2
there are a number of ways to use this.
with a variable
Dim r As Range
Set r = Range("B1")
Range("B2").Value = r.Column
with activecell
range("c1").select
Range("B2").Value = activecell.Column
and there are others.

hope this gets you started
regards
FSt1
 
Thanks, but I Don't want to write any data to the worksheet. I have a
userform that asks in which column certain data is. The response will be the
column letter.

Thanks for the suggestion though.
 
Perhaps something like this:

Range(strColEntered & "1").Column

Where strColEntered is a variable containing the Column Letter entered by
the user.

Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 
Yup, That's the spot. I knew my 14 lines of code was not the best way. How
do you MVP's keep up with all the questions?

Thank you !!
 
PS: I posted another question titled 'How to get Popup Text help to work' on
1/4. 12.25 AM PST. Chip Pearson answered part of my question about MSForms
Controls and Windows handles for them but not actually about whether or not
UserForms actually do not support What's This help.
 
You're very welcome....I'm glad I could help

***********
Regards,
Ron

XL2003, WinXP
 
Best to follow-up at that post. It'll probably get overlooked in this one.

***********
Regards,
Ron

XL2003, WinXP
 

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

Back
Top