How to return to the worksheet a macro was called from?
18,188
Save the active sheet in a variable, then, after your macro finished, select the sheet within the variable again:
' at the start of your macro:
Dim sourceSheet as Worksheet
set sourceSheet = ActiveSheet
' at the end of your macro:
Call sourceSheet.Activate
Author by
Tom
Updated on June 13, 2022Comments
-
Tom almost 2 years
I have a macro that is duplicated on buttons on 3 worksheets which moves between worksheets and at the moment once the macro command is completed I have it set to return to the 3rd sheet every time. Is there a command I can put in the code that would return the view to the sheet that the macro was activated on in the first place rather than a set sheet.