triggering a macro when a formula result changes

mrclox

New Member
Joined
Nov 24, 2005
Messages
46
Hi, can anyone tell me if its possible and if so how i can trigger a macro automatically when a formula result changes a cell? I can get it to trigger when a formula result changes using this...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo EndMacro
If Not Target.HasFormula Then
Set rng = Target.Dependents
If Not Intersect(Range("A1"), rng) Is Nothing Then
If Range("A1").Value > 200 Then YourMacroName
End If
End If
EndMacro:
End Sub

but it requires human mouse strokes to fire. I want it to do this automatically with no human intervention..
Thanks in advance for any help.

Tricky one?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi
try
Sheet_Calculate

Code:
Private Sub Worksheet_Calculate()
If Range("a1").Value > 200 Then
    'Your Macro
End If
End Sub
 
Upvote 0
That works but it the macro goes into a loop eventually crashing excel , is there a way for this to trigger the macro just once until the criteria of >200 goes false then true again
thanks for your help so far!
 
Upvote 0
Hi,

Try
Code:
Private Sub Worksheet_Calculate() 
If Range("a1").Value > 200 Then 
    Application.Enableevents=False
    'Your Macro 
    Application.Enableevents=True
End If 
End Sub
 
Upvote 0
Thank you people , the internet is a wonderful thing.. you have solved my problem, when my automated horse racing spreadsheet makes its first million i will treat you all!
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,179
Members
448,871
Latest member
hengshankouniuniu

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