change event
Try:
First, name your range, say, "CheckRange"
Then a regular code module:
Public vOldValues As Variant
In the ThisWorkbook code module:
Private Sub Workbook_Open()
vOldValues = ThisWorkbook.Names("CheckRange").RefersToRange.Val ue
End Sub
In the worksheet code module that contains CheckRange:
Private Sub Worksheet_Calculate()
Dim i As Long
With Range("CheckRange")
For i = 1 to .Cells.Count
If .Cells(i).Value < vOldValues(i, 1) Then
vOldValues(i, 1) = .Cells(i).Value
Macro2
End If
Next i
End With
End Sub
Or, if you only want Macro2 to run once, no matter how many cells have
changed:
Private Sub Worksheet_Calculate()
Dim i As Long
With Range("CheckRange")
For i = 1 to .Cells.Count
If .Cells(i).Value < vOldValues(i, 1) Then
vOldValues = .Value
Macro2
End If
Next i
End With
End Sub
In article ,
enyaw wrote:
I would also like it to work for the range c38:c51.
|