Convert Column letter to number

G

Guest

Function courtesy of Chip Pearson:


Function ColumnNumber(ColLetter) As Integer
ColumnNumber = Cells(1, ColLetter).Column
End Function
 
G

Gary Keramidas

and from bob phillips
'-----------------------------------------------------------------
Function ColumnLetter(Col As Long)
'-----------------------------------------------------------------
Dim sColumn As String
sColumn = Split(Columns(Col).Address(, False), ":")(1)
ColumnLetter = sColumn
End Function
 
B

Bob Phillips

colNum = Range(colLetter & "1").column

where colLetter is a variable with the letter(s) in it.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
U

utkarsh.majmudar

A simple one:
Sub Test()
colname = InputBox("Enter column")
'This is the one that does the trick
outp = Columns(colname).Column
MsgBox ("col no is " & outp)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top