Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA Filtered Subtotal - require sheet activation? | Excel Programming | |||
Sheet activation | Excel Discussion (Misc queries) | |||
Changing the activation of a sheet that is unactive and undefined | Excel Programming | |||
macro on Sheet activation | Excel Programming | |||
Sheet protection error msg - Unrequested sheet activation | Excel Programming |