Alpha to Numeral column name

  • Thread starter Thread starter danpt
  • Start date Start date
D

danpt

I need a macro or function to translate alphabetic column name to numeral
column number like:
Sub alphatonumeral()
Dim alpha, numeral As Variant
alpha = UCase(InputBox(prompt:="What is the alphabetic column name?"))
' translation body will be similar to formula "=column(BA:BA)" if input
alpha is BA
numeral = 53 ' for BA
MsgBox numeral
End Sub
 
Sub Numerify()
Dim s As String, n As Long, r As Range
s = Application.InputBox(Prompt:="give me the letters", Type:=2)
Set r = Range(s & 1)
MsgBox (r.Column)
End Sub
 
Thank you, great help

Gary''s Student said:
Sub Numerify()
Dim s As String, n As Long, r As Range
s = Application.InputBox(Prompt:="give me the letters", Type:=2)
Set r = Range(s & 1)
MsgBox (r.Column)
End Sub
 
If you wanted to do this directly on the worksheet without using a macro,
then you could use this formula (where your column letters are assumed to be
in A1)...

=IF(A1="","",COLUMN(INDIRECT(A1&"1")))
 
Back
Top