T
Tornados
Hi all,
I have this code implemented, which should prohibit the CDO_Send macr
to run if it already ran 10 minutes ago..
However, somehow it currently does not trigger the macro at al
anymore. Sometimes when i just opened the file and something changes i
does trigger.., there is no logic behind it though. I've tried to mov
the dlastsent line between the 'end if' at the bottom.. yet no matte
what i do, it does not work.
So now and then it s) also gives a type mismatch error in thi
line:
If myVals(iRow, iCol) = myRng.Cells(iRow, iCol) Then
Cells in the range change through an if function which itselfs relate
to another cell in which values change due to an dde function in agai
another cell......
I hope someone can help me out here....
============================
Option Explicit
Private Sub Worksheet_Calculate()
Static dLastSent As Double
If dLastSent = 0 Then dLastSent = Now - TimeValue("00:11:00")
If Now >= (dLastSent + TimeValue("00:10:00")) Then
Static myVals As Variant
Dim iRow As Long
Dim iCol As Long
Dim myRng As Range
Dim SomethingChanged As Boolean
Set myRng = Me.Range("i4:n27")
If IsEmpty(myVals) Then
myVals = myRng.Value
Else
SomethingChanged = False
For iRow = LBound(myVals, 1) To UBound(myVals, 1)
For iCol = LBound(myVals, 2) To UBound(myVals, 2)
If myVals(iRow, iCol) = myRng.Cells(iRow, iCol) Then
'do nothing--no change here
Else
SomethingChanged = True
CDO_Send
dLastSent = Now
End If
Next iCol
Next iRow
If SomethingChanged Then
myVals = myRng.Value
End If
End If
End If
End Sub
===============
I have this code implemented, which should prohibit the CDO_Send macr
to run if it already ran 10 minutes ago..
However, somehow it currently does not trigger the macro at al
anymore. Sometimes when i just opened the file and something changes i
does trigger.., there is no logic behind it though. I've tried to mov
the dlastsent line between the 'end if' at the bottom.. yet no matte
what i do, it does not work.
So now and then it s) also gives a type mismatch error in thi
line:
If myVals(iRow, iCol) = myRng.Cells(iRow, iCol) Then
Cells in the range change through an if function which itselfs relate
to another cell in which values change due to an dde function in agai
another cell......
I hope someone can help me out here....
============================
Option Explicit
Private Sub Worksheet_Calculate()
Static dLastSent As Double
If dLastSent = 0 Then dLastSent = Now - TimeValue("00:11:00")
If Now >= (dLastSent + TimeValue("00:10:00")) Then
Static myVals As Variant
Dim iRow As Long
Dim iCol As Long
Dim myRng As Range
Dim SomethingChanged As Boolean
Set myRng = Me.Range("i4:n27")
If IsEmpty(myVals) Then
myVals = myRng.Value
Else
SomethingChanged = False
For iRow = LBound(myVals, 1) To UBound(myVals, 1)
For iCol = LBound(myVals, 2) To UBound(myVals, 2)
If myVals(iRow, iCol) = myRng.Cells(iRow, iCol) Then
'do nothing--no change here
Else
SomethingChanged = True
CDO_Send
dLastSent = Now
End If
Next iCol
Next iRow
If SomethingChanged Then
myVals = myRng.Value
End If
End If
End If
End Sub
===============