use a macro to temporarily stop Sub worksheet_activate()

still learning

Well-known Member
Joined
Jan 15, 2010
Messages
784
Office Version
  1. 365
Platform
  1. Windows
Hi
Can I make a macro like a toggle button that will stop a Sub worksheet_activate macro?
I have a worksheet that i sometimes have to copy and paste to it or from it and every time i go back to it, i'm in the wrong place.
what i do now is put a ' on each line, then when i'm ready to save the sheet, i delete the '
I would like to put an icon on the ribbon.
The thing i don't how to do is write the macro.
I only want to deable the activate macro for the sheet i'm working on (not the whole workbook)

mike
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi stilll earnin,

what about using
Code:
Application.EnableEvents = False
to stop the events at the beginning of the macro and
Code:
Application.EnableEvents = True
at the end. Another possibility would be to use a checkbox on the sheet and evaluate from there: checked will run the event, uncheck omit it.

Ciao,
Holger
 
Upvote 0
Hi HaHoBe
I've used that code before and it seems to disable all the workbooks. i only need to disable on sheet
May be I was putting it in the wrong place.

mike
 
Upvote 0
Hi Fluff
yep that's why i was wondering if i can make a macro.
I only want to for the one sheet, not the whole workbook.

mike
 
Upvote 0
Rather than commenting out the lines one by one you can just select the entire code & click the "Comment Block" icon in the Editor
1621869650569.png
 
Upvote 0
Solution
Hi Mike,

an alzernative to commenting the code might be to add these lines at the top of the the Worksheet-Activate code
Code:
...
Const blnStopEvent As Boolean = False

If blnStopEvent Then Exit Sub
...
As long as the constant shows False the code will be executed, on True no event will be raised.

I have a worksheet that i sometimes have to copy and paste to it or from it and every time i go back to it, i'm in the wrong place.

Can´t you stay away from changing sheets by fully qualifing the ranges you are working with?

Ciao,
Holger
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,575
Members
449,039
Latest member
Arbind kumar

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