worksheet calculate repeatedly calling itself

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've found out that worksheet change will not pick up when my cell changes
(the cell is linked by DDE to another application). So I'm picking up the
change using worksheet calculate, but the procedure is repeatedly calling
itself, despite me using Application.EnableEvents to disable the events
during the procedure. Add_new_record is the procedure that keeps being
repeated, but I only want it to run once. Any ideas? Here is the code;

Sub Worksheet_Calculate()
If Range("Q1").Value = "1" Then
Application.EnableEvents = False
Add_new_record
End If
Application.EnableEvents = True
End Sub

Thanks,
Craig.
 
Application.EnableEvents would disable events from firing. From the code
shown, it is impossible to diagnose why you might be getting unexpected
results. However, once Q1 takes on the value of 1, everytime there is a
calculation, you will fire the Add_new_record macro.

If you are trying to react to a DDE update, then try using SetlinkonData
which is a property of the Workbook object.
 
Back
Top