Code behind tab not executing

atf32

Board Regular
Joined
Apr 13, 2011
Messages
157
For some reason, all code (i.e., onchange, worksheet_activate, worksheet_deactivate) behind my tabs are not executing automatically. I know that they run, bc, I can step in them to execute them. Also all of my other code runs as expected. Could there actually be a setting that is preventing worksheet code from executing, but not the other code?:confused::eek:
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Chances are you disabled Events in one of your code blocks, and didn't re-enable it.
In order to avoid changes made by code triggering itself and getting caught in an endless loop, this line of code is often used:
Code:
Application.EnableEvents = False
This disables the automatic running of your event code.
However, it need to be turned on again as your code finishes running, or else the "automatic" code won't work anymore.
So any block of code where you have the line above, you will also need this line at some point after it:
Code:
Application.EnableEvents = True
However, if you exit the code before getting to this last line (either because you placed it in the wrong place and are exiting before hitting it, or because your code stopped because it hit an error), you will experience what you currently describing.

You can just manually turn it back on by running this short little procedure.
Code:
Sub ReEnableEvents()
    Application.EnableEvents = True
End Sub
And make sure that you address any parts of your code that could be causing this to happen.
 
Upvote 0
You are absolutely right!!! Was a very long day, so I totally over looked that. Thank you very much.:)
 
Upvote 0
You are welcome.
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,122
Members
448,550
Latest member
CAT RG

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