Macro triggered by Worksheet Activate - endless loop

Stevelin

New Member
Joined
Dec 5, 2010
Messages
8
I have a multi-sheet workbook. The first sheet is a summary of results from the rest of the workbook. I would like this summary sheet to auto-refresh itself each time the sheet is activated. The VBA code triggered by the Worksheet/Activate event feeds some parameters out to other sheets, then copies back the results to the summary sheet of the workbook. While doing so, it keeps "reactivating" the first sheet, causing it to get into an endless loop that is triggered by the Worksheet/Activate event. Any ideas re how to avoid this? Essentially, I'd like the Worksheet/Activate event to go dormant for 15 seconds or so each time it is triggered.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You need this

Application.EnableEvents=False
'
'code here
'
Application.EnableEvents=True
 
Upvote 0
As always, do not Select or Activate worksheets, unless aboslutely needed :) Application.EnableEvents code should not be in play here.

While getting back the result from the other sheets, why do you activate the summary sheet?
 
Upvote 0
Thank you VoG, that did the job

Still somewhat of a VBA novice - I don't think I was actually selecting or activating the other sheets. Instead my code was doing things like range("name").copy followed by a paste/special on the first sheet, which was already active. But nonetheless it was setting off the Worksheet Activate event for some reason
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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