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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
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,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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