MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Dumb Question: How do I make Excel go back to the active cell after a macro runs?

Posted by Chris Rock on July 06, 2001 6:00 AM

Someone once said: "There's no such thing as a stupid question." Well, this proves that theory wrong.

I have a macro that goes and selects a certain row when it runs, but I need it to go back to the cell that was active before the macro was run. What's the code for that?

For example, a user is in cell A5 (or ANY cell), runs this macro with a button click, the macro runs, and at the end of the macro, the cell the user was in (A5) becomes the active cell again.

Maybe someone could enlighten me?

Posted by AB on July 06, 2001 6:23 AM

Sub MyMacro()

RetCell = activecell.address

'MyMacro Code Here


End Sub

AaronThe Excel Logic Page

Posted by Joe Was on July 06, 2001 9:54 AM

Just add: Range("A1").Select
to the end of your code before the End statement.

"A1" is any cell you want the macro to end in!