Worksheet Change Event Problems - endless loop

holditall

New Member
Joined
Dec 30, 2008
Messages
17
Dear all,

I have a problem with the

Worksheet_Change Event. The below code (attached to the sheet) calls a macro wich does some calculation. This works fine so far. But the macro in the end shell alter some cells in the actual sheet then. If it does so, the Change Event is called again and the whole routine starts again over. So I am trapped in a endless loop.

Is there a way to aviod this? Like dissabling intermediately the Change Event functionality in the macro?

Best Axel!


Private Sub Worksheet_Change(ByVal Target As Range)
'Do nothing if more than one cell is changed or content deleted
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Row > 3 And Target.Row < 23 And Target.Column > 2 And Target.Row < 28 Then
Application.ScreenUpdating = False
RunUpdateallSpecimenMacro
RefreshHighlighting
Application.ScreenUpdating = True


End If

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Before changing cells within the routine, do Application.EnableEvents=False, and afterwards reset it by doing Application.EnableEvents=True
 
Upvote 0
Hi,

Try enveloping the offending code with
Code:
Application.EnableEvents = False
and
Code:
Application.EnableEvents = True
 
Upvote 0

Forum statistics

Threads
1,215,509
Messages
6,125,216
Members
449,215
Latest member
texmansru47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top