Discussion Locked

Go to Active Cell in a Macro?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
In a Excel macro, how do you make the macro start an action (such as inserting a row) at the "active cell" rather than at a specific cell such as "C4"? When using the "Record Macro" it keeps entering the specific cell.

5 replies

by dklippert

When you record the macro, you can click the Relative Address button just to the right of the Stop button on the Record macro toolbar. This will toggle between Absolute and Relative addressing.

Sub AddaRow
Selection.EntireRow.Insert
End Sub

by shanghai sam

I believe what I'm needing has to do with the R1C1 style of addresses. I tried typing the F4 key which is what I use for the absolute address but it didn't the way the macro recorded. I also changed to the R1C1 style but it didn't change the way the macro recorded either.

by dklippert

When you are recording a macro, you dont use the F4 key. Start the macro recorder. This from the Help file:

"If you want the macro to run relative to the position of the active cell, record it using relative cell references button. On the Stop Recording toolbar, click Relative Reference (just to the right of the Stop button) so that it is selected. Excel will continue to record macros with relative references until you quit Excel or until you click Relative Reference again, so that it is not selected."

This discussion is closed to new replies.