Return to the Active Worksheet at time macro is run

alyssa75

Board Regular
Joined
May 14, 2007
Messages
240
How can I tell my macro to come back to the worksheet the macro is run from....using ActiveWorksheet or something like that? I don't want to tell it specifically by name since the macro can be run from different sheets.

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
You just want to tag your worksheet when the macro starts:
Code:
Sub Macro1()
Dim ws As Worksheet

    Set ws = ActiveSheet
    
[COLOR="SeaGreen"]    '//Do Code
    '//Do Code[/COLOR]
    
    ws.Activate

End Sub

ξ
 
Upvote 0
You shouldn't need to unless the code activates or selects another worksheet and you almost never need to do that.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top