Global ChangedAry(10 To 100, 10 To 500) As Integer
Global DDEValues(10 To 100, 10 To 500) As Double
Global Changes As Integer
Global MonitorCount As Long
'
'
This is an example of your function that gets the DDE. You will have to add the code I have into yours
Function GetDDE(R As Range) As Variant
Dim V As Double
Dim T As Long
Dim Addr As String
Dim Rw As Long, Col As Long
'Call the DDE and declare value of function
GetDDE = 9 'This is a test statement
Addr = R.Address
'Get Tracking value
V = Sheets("Track").Range(Addr).Value
If V <> GetDDE Then 'The last value does not equal the new value
DDEValues(R.Column, R.Row) = GetDDE
ChangedAry(R.Column, R.Row) = 1
Changes = 1
Else 'It does equal; check the time
If Sheets("Monitor").Range(Addr) >= Now() Then 'Beyond the time; reset color
ChangedAry(R.Column, R.Row) = -1
Changes = 1
End If
End If
End Function
'Only called after Worksheet calculate
Sub CheckChanges()
Dim X As Long
Dim Y As Long
For X = 10 To 100
For Y = 10 To 500
If ChangedAry(X, Y) = 1 Then
Sheets("Track").Cells(Y, X) = DDEValues(X, Y)
Sheets("Monitor").Cells(Y, X) = Now() + TimeValue("00:00:10")
ChangedAry(X, Y) = 0
With Sheets("Watch").Cells(Y, X).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = -9.99786370433668E-02
.PatternTintAndShade = 0
End With
ElseIf ChangedAry(X, Y) = -1 Then
With Sheets("Watch").Cells(Y, X).Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Sheets("Monitor").Cells(Y, X).ClearContents
ChangedAry(X, Y) = 0
End If
Next Y
Next X
Changes = 0
Call CheckWatch
End Sub
'
'This Sub changed
Public Sub GoWatch()
Dim Cell As Range
Dim MSht As Worksheet
Dim MRng As Range
Dim Addr As String
If MonitorCount = 0 Then Exit Sub
Application.EnableEvents = False
Set MSht = Sheets("Monitor")
For Each Cell In Sheets("Watch").Range("Watch_Rng")
Set MRng = MSht.Range(Cell.Address)
If Len(MRng.Text) > 0 And MRng.Value <= Now() Then
With Cell.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
MRng.ClearContents
MonitorCount = MonitorCount - 1
End If
Next Cell
Application.EnableEvents = True
If MonitorCount > 0 Then
Application.OnTime Now() + TimeValue("00:00:05"), "GoWatch"
End If
End Sub
'
'
'This Sub Changed, maybe
Sub CheckWatch()
Dim MSht As Worksheet
Dim Addr As String
Set MSht = Sheets("Monitor")
Addr = Sheets("Watch").Range("Watch_Rng").Address
MonitorCount = Application.WorksheetFunction.CountA(MSht.Range(Addr))
If MonitorCount = 0 Then Exit Sub
Call GoWatch
End Sub