Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() is it possible to stop the selection change event procedure from being triggered from within a worksheet change event code i.e i have an event by slection that will begin the start of event by change but keeps looping when triggered if the change would stop the selection code once activated it will prevent any looping hope this makes sense i would imagine it be something similar to either exit private sub worksheet_selectionchange or end provate sub worksheet_selectionchange however neither of these codes work please help me thanks -- short_n_curly ------------------------------------------------------------------------ short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576 View this thread: http://www.excelforum.com/showthread...hreadid=382587 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use Application.EnableEvents = False to stop events from firing.
Set it back to true at the appropriate place in your code. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "short_n_curly" wrote in message news:short_n_curly.1rau2l_1119899158.6547@excelfor um-nospam.com... is it possible to stop the selection change event procedure from being triggered from within a worksheet change event code i.e i have an event by slection that will begin the start of event by change but keeps looping when triggered if the change would stop the selection code once activated it will prevent any looping hope this makes sense i would imagine it be something similar to either exit private sub worksheet_selectionchange or end provate sub worksheet_selectionchange however neither of these codes work please help me thanks -- short_n_curly ------------------------------------------------------------------------ short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576 View this thread: http://www.excelforum.com/showthread...hreadid=382587 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am assuming that your selection change event code triggers a selection
change and that is resulting in a recursive call. To fix that you can set application.enableEvents to ignore the events something like this Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error GoTo ErrorHandler Application.EnableEvents = False ErrorHandler: Application.EnableEvents = True End Sub As always when switching application settings it is safest to have an error handler to reset the applicaton in case your code crashes... -- HTH... Jim Thomlinson "short_n_curly" wrote: is it possible to stop the selection change event procedure from being triggered from within a worksheet change event code i.e i have an event by slection that will begin the start of event by change but keeps looping when triggered if the change would stop the selection code once activated it will prevent any looping hope this makes sense i would imagine it be something similar to either exit private sub worksheet_selectionchange or end provate sub worksheet_selectionchange however neither of these codes work please help me thanks -- short_n_curly ------------------------------------------------------------------------ short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576 View this thread: http://www.excelforum.com/showthread...hreadid=382587 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just some added information:
Jim, either you mistyped or misread. He said the change event is causing a selectionchange to fire. In any event, while the solution is certainly applicable, a better all around solution might be to avoid making a selection in the change event. In other words, if the OP is using recorder style code like Range("A1").Select Selection.Value = 21 Range("B9").Select then this should be avoided with just range("A1").Value = 21 which doesn't trigger a selectionchange. -- Regards, Tom Ogilvy "Jim Thomlinson" wrote in message ... I am assuming that your selection change event code triggers a selection change and that is resulting in a recursive call. To fix that you can set application.enableEvents to ignore the events something like this Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error GoTo ErrorHandler Application.EnableEvents = False ErrorHandler: Application.EnableEvents = True End Sub As always when switching application settings it is safest to have an error handler to reset the applicaton in case your code crashes... -- HTH... Jim Thomlinson "short_n_curly" wrote: is it possible to stop the selection change event procedure from being triggered from within a worksheet change event code i.e i have an event by slection that will begin the start of event by change but keeps looping when triggered if the change would stop the selection code once activated it will prevent any looping hope this makes sense i would imagine it be something similar to either exit private sub worksheet_selectionchange or end provate sub worksheet_selectionchange however neither of these codes work please help me thanks -- short_n_curly ------------------------------------------------------------------------ short_n_curly's Profile: http://www.excelforum.com/member.php...o&userid=21576 View this thread: http://www.excelforum.com/showthread...hreadid=382587 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
workbook_Open event Procedure | Excel Discussion (Misc queries) | |||
workbook_Open event Procedure | Excel Discussion (Misc queries) | |||
Event Procedure | Excel Programming | |||
Event Procedure again | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming |