ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hot to Get a Column Number from a column letter (https://www.excelbanter.com/excel-programming/403727-hot-get-column-number-column-letter.html)

TWR

Hot to Get a Column Number from a column letter
 
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?

FSt1

Hot to Get a Column Number from a column letter
 
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

"TWR" wrote:

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?


TWR

Hot to Get a Column Number from a column letter
 
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.

"FSt1" wrote:

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

"TWR" wrote:

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?


Ron Coderre

Hot to Get a Column Number from a column letter
 
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)

"TWR" wrote in message
...
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.

"FSt1" wrote:

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

"TWR" wrote:

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?




TWR

Hot to Get a Column Number from a column letter
 
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 !!

"Ron Coderre" wrote:

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)

"TWR" wrote in message
...
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.

"FSt1" wrote:

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

"TWR" wrote:

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?





TWR

Hot to Get a Column Number from a column letter
 
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.

"Ron Coderre" wrote:

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)

"TWR" wrote in message
...
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.

"FSt1" wrote:

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

"TWR" wrote:

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?





Ron Coderre

Hot to Get a Column Number from a column letter
 
You're very welcome....I'm glad I could help

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

XL2003, WinXP


"TWR" wrote:

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 !!

"Ron Coderre" wrote:

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)

"TWR" wrote in message
...
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.

"FSt1" wrote:

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

"TWR" wrote:

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?





Ron Coderre

Hot to Get a Column Number from a column letter
 
Best to follow-up at that post. It'll probably get overlooked in this one.

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

XL2003, WinXP


"TWR" wrote:

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.

"Ron Coderre" wrote:

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)

"TWR" wrote in message
...
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.

"FSt1" wrote:

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

"TWR" wrote:

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?






All times are GMT +1. The time now is 04:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com