Hi I have a simple question this time.
I'm using Office XP and I would like to know how to store the current cell's location in a variable that I create in VBA.
-DragonL
Hi I have a simple question this time.
I'm using Office XP and I would like to know how to store the current cell's location in a variable that I create in VBA.
-DragonL
DISREGARD THIS MESSAGE.
Didn't read the initial msg correctly.
Hi DL,
The current cell in Excel is referred to as the ActiveCell. You can store this in a variable like this:[vba]Sub Test()
Dim rngCell As Range
Set rngCell = ActiveCell
MsgBox rngCell.Address
End Sub[/vba]HTH
I don't mean to be picky, and I think you can get what you asked from Richie's post. But to put the address directly into a variable:
Sub Test()
Dim CellAddress As String
CellAddress = ActiveCell.Address
MsgBox CellAddress
End Sub
EDIT: P.S. If you have more than a single cell selected, this will return the address of the top left cell. If you want the address of the entire range selected, use:
CellAddress = Selection.Address
Don’t have an account yet? Register yourself now and be a part of our community!