Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Need to prevent call Sub Worksheet_Activate() during macro.

I've run into a problem.

I have code that is supposed to be run everytime I activate the sheet,
which is located in the Private Sub Worksheet_Activate(),

Problem is that somewhere else in the code I have a routine to hide
all sheets except this particular one and Excel calls the Private Sub
Worksheet_Activate().
There are other instances as well that excel call for the sub when I
need it to to something on that sheet.
The problem is that Private Sub Worksheet_Activate() does some stuff
that I only want to be done when I select the sheet not when running
code.

Is there an easy way to make Excel ignore the sub unless I click on
the sheet tab to activate it?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Need to prevent call Sub Worksheet_Activate() during macro.

Application.EnableEvents = False
'do stuff here
Application.EnableEvents = True

make sure to add error handling whenever you use this type of approach: if
an error occurs when EnableEvents is false then it will not revert back to
True when your code exits.

Tim



wrote in message
...
I've run into a problem.

I have code that is supposed to be run everytime I activate the sheet,
which is located in the Private Sub Worksheet_Activate(),

Problem is that somewhere else in the code I have a routine to hide
all sheets except this particular one and Excel calls the Private Sub
Worksheet_Activate().
There are other instances as well that excel call for the sub when I
need it to to something on that sheet.
The problem is that Private Sub Worksheet_Activate() does some stuff
that I only want to be done when I select the sheet not when running
code.

Is there an easy way to make Excel ignore the sub unless I click on
the sheet tab to activate it?
Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Need to prevent call Sub Worksheet_Activate() during macro.

Thanks guys.
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
Call macro stored in Excel workbook from Outlook's macro Gvaram Excel Programming 0 October 4th 06 05:47 PM
Worksheet_Activate greg Excel Programming 2 September 26th 06 01:24 PM
Worksheet_Activate Pozzo Excel Programming 5 June 7th 04 07:39 PM
Worksheet_Activate Jim Carlock[_2_] Excel Programming 2 September 25th 03 12:47 AM
Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub? Scott Lyon Excel Programming 3 August 19th 03 03:03 PM


All times are GMT +1. The time now is 08:40 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"