converting column reference IE: from range("c1") format to c

Egad

New Member
Joined
Oct 22, 2002
Messages
39
Is there an easy eay in VBA to convert a column reference from a letter to a number? IE: cell reference from range("c1") format to cells(3,1) format?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Use the Row and Column properties like this:

r = Range("C1").Row
c = Range("C1").Column
Cells(r,c).Select

It's harder the other way round!
 
Upvote 0
Not sure, (also not sure why you would need to do so) but you could use something like this to return the value of cell(1,1):-

MsgBox Cells(Range("A1").Row, Range("A1").Column)
 
Upvote 0
Try:

Sub IndexToStringConvertiA1C1()

Dim str As String
Dim Riga As Long
Dim colonna As Long
Riga = Application.InputBox(prompt:="Riga", Type:=1)
colonna = Application.InputBox(prompt:="Colonna", Type:=1)
Convert = IndexToString(Riga, colonna, str)
MsgBox str

End Sub
Function IndexToString(row As Long, col As Long, strResult As String)
strResult = ""
If col > 26 Then
strResult = Chr(Asc("A") + Int(col - 1) / 26 - 1)
End If
strResult = strResult & Chr(Asc("A") + ((col - 1) Mod 26))
strResult = strResult & row
End Function
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,616
Members
449,238
Latest member
wcbyers

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