![]() |
Running Macro at sheet activation
I would like to have a macor run when certain pages are opened. This
is what I have tried... Private Sub Worksheet_Activate () Application.Run "Macroname" End Sub All I get is the screen flashing at me about 50 times and the macro doesn't run. My hope is to have a macro run on activation and another run on deactivation. I'm looking for the correct wording. I could sure use some help. Thanks! |
Running Macro at sheet activation
HI,
Could you mail your macro code ? "gfkbob" wrote in message oups.com... I would like to have a macor run when certain pages are opened. This is what I have tried... Private Sub Worksheet_Activate () Application.Run "Macroname" End Sub All I get is the screen flashing at me about 50 times and the macro doesn't run. My hope is to have a macro run on activation and another run on deactivation. I'm looking for the correct wording. I could sure use some help. Thanks! |
Running Macro at sheet activation
If your screen if flashing, then that would be an indication of
1) the macro is running and 2) very poor coding - using recorder style code. It sounds like your code activates sheets and therefore triggers your event code to fire over and over in a recursive fashion. Try it this way Private Sub Worksheet_Activate () On Error goto errHandler Application.EnableEvents = False Macroname errHandler: Application.EnableEvents = True End Sub This is somewhat of a bandaid approach, but should get you going. -- Regards, Tom Ogilvy "gfkbob" wrote: I would like to have a macor run when certain pages are opened. This is what I have tried... Private Sub Worksheet_Activate () Application.Run "Macroname" End Sub All I get is the screen flashing at me about 50 times and the macro doesn't run. My hope is to have a macro run on activation and another run on deactivation. I'm looking for the correct wording. I could sure use some help. Thanks! |
All times are GMT +1. The time now is 08:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com