Simple Convert Question

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
I have a string that has a cell reference such as "A1". I would like to retrieve the column number and put it into an integer. Is this possible?

Thanks...
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I would like to retrieve the column number and put it into an integer.
What does this mean? Do you mean to say you want to convert the column Letter to a number?
 
Upvote 0
That's correct schielrn... I would have created a string with A1 through whatever. I would like to convert the letter A, B, C, etc... to 1, 2, 3, etc... I need to do this in my macro...

Thanks...
 
Upvote 0
In VBA to get the column letter just use:

columnNumber = range("D1").column

This just being an example.
 
Upvote 0
For columns up to Z maybe

Code:
Sub colno()
Dim s As String, col As Integer
s = "J1"
col = Asc(Left(s, 1)) - 64
MsgBox col
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top