View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
R.VENKATARAMAN R.VENKATARAMAN is offline
external usenet poster
 
Posts: 74
Default Stop Worksheet_SelectionChange event from firing?

apologise for treading in while experts discsuss.

these three messages which were downloaded in my computer today do not
contain all the messages. then I went to google
search tool in excel and read all the messages. I have a slightly different
more complicated problem I have an event procedure in <thisworkbook
Workbook_SheetSelectionChange
sometimes when I operate any other procedure in the standard module it
automatically fires this workbook event procedure. like any non expert I
place the enableevents line false in the beginning and true at the end of
this workbook event procedure . after I finish the standard procedure I
convert these two enable events lines into comments. But it is painful and I
have to remember everytime. I shall see whether I can adapt any of the
solutions given by the experts. any specific solutions will be appreciated.


Jan Karel Pieterse wrote in message
...
Hi Bob,

I was also thinking about the variable approach which I noticed in your
other response. That approach can fail just as easily, but of course

events
only get disabled if they use that variable, other events continue ok.

My
thoughts went along the lines, is it better to be wrong some of the time
(when the variable gets knocked out), or to be wrong all of the time (if
EnableEvents get knocked out). Couldn't come to a conclusion, as the

famous
phrase '... it depends ...' kicks in, so we have to adopt a solution to

suit
(as ever ;-)).


Agreed. Another advantage I see in using a variable is when one clicks End

on
an error message, the variable gets reset to false automatically and the

event
works once more.

But as stated in this thread more than once, the only true solution is to

use
proper error handling in the subs concerned.

Whether one uses a (static or global) variable to prevent local (or even
projectwide) looping or EnableEvents to prevent global looping depends on

the
situation.
Of course to be completely foolproof, I guess it is the latter. One never
knows what other code is "active" besides ones own application.

So: Implement Error handling!!!

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com