Convert column letter to number?

  • Thread starter Thread starter Frank Marousek
  • Start date Start date
F

Frank Marousek

I'm writing a Sub that accepts a column letter as input in a UserForm. I
would like to convert this column letter to a column number for use in my
code. How is this done?
 
Why can't you use the letter?
strInput = Inputbox("Letter")
Range(strInput & 1).Select
Cells(1, strInput).Select

otherwise, if the activesheet is a worksheet then use this:
ColumnNumber = Range(strInput & 1).Column
 
Hi
This sub will return 36

Public Sub tester()
Dim Letter As String
Letter = "AJ"
MsgBox Columns(Letter & ":" & Letter).Column
End Sub

Replace letter with your UserForm input.
regards
Paul
 
Why can't you use the letter?

Using the letter works fine. It was a rookie mistake. I was getting a "Type
mismatch" error which I thought was being caused because I was feeding a
string into where an integer was expected, but it turns out that error was
being caused by something else.

Thank you!
 
Back
Top