View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Stop Worksheet_SelectionChange event from firing?

Jan,

Take your point, but judicious use of Error handling can make sure it gets
reset. I always use code like

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True

which seems to trap the situation (of course, if I stop it in debug mode it
causes problems, but that would be my problem :-)).

What other way could you manage it? If you create your own control variable,
as you have to with form events, I don't see that differs in any material
way.

--

HTH

RP
(remove nothere from the email address if mailing direct)


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

At the start set

Application.EnableEvents = False

and reset to true at the end.


I am not too fond of this method, since it disables all events and
gives you little control. And when the code falls over, all events
remain disabled and things stop working, even in other VBA projects
like addins that may rely on events.

Regards,

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