Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Filtered Subtotal - require sheet activation? [email protected][_2_] Excel Programming 3 January 27th 07 07:43 PM
Sheet activation CWillis Excel Discussion (Misc queries) 5 June 1st 06 09:50 PM
Changing the activation of a sheet that is unactive and undefined Andyjk1 Excel Programming 3 April 20th 06 06:29 PM
macro on Sheet activation [email protected] Excel Programming 3 August 29th 05 12:36 AM
Sheet protection error msg - Unrequested sheet activation deltree[_3_] Excel Programming 0 January 28th 04 06:20 PM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"