```
Private oldValueA1 As Variant, oldValueA18 As Variant
Private Sub Worksheet_Calculate()
If CStr(oldValueA1) = "" Then
Range("Z3") = 9999999
Range("Z2") = 0
End If
If CStr(oldValueA18) = "" Then
Range("Z20") = 9999999
Range("Z19") = 0
End If
If Range("A1") = oldValueA1 And Range("A18") = oldValueA18 Then Exit Sub
oldValueA1 = Range("A1").Value
oldValueA18 = Range("A18").Value
Call MacroY
End Sub
Sub MacroY()
'A1 values
Range("Z2") = WorksheetFunction.Max(Range("A1"),Range("Z2"))
If Range("Z3") = 0 Then Range("Z3") = 9999999
Range("Z3") = WorksheetFunction.Min(Range("A1"), range("Z3"))
'A18 values
Range("Z19") = WorksheetFunction.Max(Range("A18"),Range("Z19"))
If Range("Z20") = 0 Then Range("Z20") = 9999999
Range("Z20") = WorksheetFunction.Min(Range("A18"), range("Z20"))
End Sub
```