d23
Petroleum
- Dec 8, 2002
- 297
All,
I need to run a macro anytime a cell value changes, but the cell is a formula, not just a static value. I have tried the following code and it works fine if I manually enter a value in the target cell, but if I use a formula in the target cell it does not work. Is there a way to run the macro when a formula result changes? In my file cell AD61 is the sum of several cells.
Example of “Does Not Work Code”
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(Target, Range("AD61")) Is Nothing Then Speed
Application.EnableEvents = True
End Sub
Sub Speed()
Dim S As Double 'Speed RPM
S = Range("AD70")
Range("AD71").FormulaR1C1 = S
End Sub
Thanks
David
I need to run a macro anytime a cell value changes, but the cell is a formula, not just a static value. I have tried the following code and it works fine if I manually enter a value in the target cell, but if I use a formula in the target cell it does not work. Is there a way to run the macro when a formula result changes? In my file cell AD61 is the sum of several cells.
Example of “Does Not Work Code”
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Intersect(Target, Range("AD61")) Is Nothing Then Speed
Application.EnableEvents = True
End Sub
Sub Speed()
Dim S As Double 'Speed RPM
S = Range("AD70")
Range("AD71").FormulaR1C1 = S
End Sub
Thanks
David