Getting active cell address

  • Thread starter Thread starter bmwmcrider
  • Start date Start date
B

bmwmcrider

Hi,

I am not an Excel VBA expert and have run into a roadblock in attempts
to create a VBA script to manipulate data in S/S cells. What I want
to do is retrieve the address of the active cell. From that I want to
get the row number so that I can go to other cell in that row to read
and modify cell values.

Reviewing all the Excel classes and help files I couldn't seem to
locate a method that returns an object that contains the currently
active cell address.

Any help would be appreciated. TIA ...

Mike
 
-----Original Message-----
Hi,

I am not an Excel VBA expert and have run into a roadblock in attempts
to create a VBA script to manipulate data in S/S cells. What I want
to do is retrieve the address of the active cell. From that I want to
get the row number so that I can go to other cell in that row to read
and modify cell values.

Reviewing all the Excel classes and help files I couldn't seem to
locate a method that returns an object that contains the currently
active cell address.

Any help would be appreciated. TIA ...

Mike
.
Hi Mike

Use the ActiveCell.Address as:
Sub ActiveCellAddress()
Dim myCellAddress As String
myCellAddress = ActiveCell.Address
MsgBox "Active cell address: " & myCellAddress
End Sub
 
Hi Mike

You can read the row number directly:

ActiveCell.Row

(Likewise for .Column and .Address)
 
Just to add to the previous answers...

You may also want to take a look at the Offset property.

Troy


Sub Test1()

'Change the cell 1 column to the right.
ActiveCell.Offset(0, 1).Value = 123

'Change the cell 2 columns to the right.
ActiveCell.Offset(0, 2) = 456

End Sub
 
Hi Gregas, Harald

Thanks for yor help. After going back and studying the properties
some more I too eventually figured out how to achieve my objective.

I should get a book on writing VBA scripts for Excel rather than rely
on the help pages. Any recommendations?

Mike
 
Back
Top