ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Alpha to Numeral column name (https://www.excelbanter.com/excel-discussion-misc-queries/233074-alpha-numeral-column-name.html)

danpt

Alpha to Numeral column name
 
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

Gary''s Student

Alpha to Numeral column name
 
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

--
Gary''s Student - gsnu200856


"danpt" wrote:

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


danpt

Alpha to Numeral column name
 
Thank you, great help

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200856


"danpt" wrote:

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


Rick Rothstein

Alpha to Numeral column name
 
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")))

--
Rick (MVP - Excel)


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




All times are GMT +1. The time now is 03:21 PM.

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