Forum Discussion
Greg Bonaparte
Apr 21, 2019Iron Contributor
Suppress this first initialization of the private macro
I have a "private worksheet" below that monitors U30 THRU U629. My macro starts off by clearing all contents of U30 thru u629 prompting this private macro to initiate. I would like to suppress this f...
- Apr 21, 2019I assume you’re clearing the range in another macro? Before you clear, you’ll want to turn off events using
Application.EnableEvents = False
Then after you clear the range, reset Application.EnableEvents = True
MichaelMays
Apr 21, 2019Copper Contributor
I assume you’re clearing the range in another macro? Before you clear, you’ll want to turn off events using
Application.EnableEvents = False
Then after you clear the range, reset Application.EnableEvents = True
Application.EnableEvents = False
Then after you clear the range, reset Application.EnableEvents = True
- Greg BonaparteApr 21, 2019Iron Contributor
Michael thank you! With your help my final code to fix this issue looks like this and is embedded in the macro that does the clearing of the contents. This worked perfectly:
Application.EnableEvents = False
Range("Z10,Z8,R2,T2:T27,U2:U11,V2:W5,U30:U629").Select
Range("U30").Activate
Application.CutCopyMode = False
Selection.ClearContents
Application.EnableEvents = True- MichaelMaysApr 21, 2019Copper ContributorGlad it worked! Something you can also do to make code run more quickly is to avoid selecting and activating ranges. Instead, use: Range("Z10,Z8,R2,T2:T27,U2:U11,V2:W5,U30:U629").ClearContents
- Greg BonaparteApr 21, 2019Iron Contributor
Wow I select and activate in multiple macros causing my entire process to take about 6mins. I always wondered how to make things run faster. I will begin implementing your suggestion. Ill get back to you soon with the result as I have much code to modify. Thanks