Hi folks!
The following VBA code is applied to a single worksheet, it triggers and email send (via Outlook) when a cell in a row becomes "Overdue". It actually works fine, however I've noticed upon opening the workbook it takes an AGE to calculate and then allow me to modify the worksheets.
Do you have any idea what I can apply to speed it up? I need to ensure other code within the same workbook isn't affected.
The following VBA code is applied to a single worksheet, it triggers and email send (via Outlook) when a cell in a row becomes "Overdue". It actually works fine, however I've noticed upon opening the workbook it takes an AGE to calculate and then allow me to modify the worksheets.
Do you have any idea what I can apply to speed it up? I need to ensure other code within the same workbook isn't affected.
Code:
Private Sub Worksheet_Calculate()
Dim FormulaRange As Range
Dim NotSentMsg As String
Dim MyMsg As String
Dim SentMsg As String
Dim MyLimit As String
NotSentMsg = "Email Reminder Not Sent"
SentMsg = "Email Reminder Sent"
'Above the MyLimit value it will run the macro
MyLimit = "OVERDUE"
Sheets("Contractor Update").Select
Application.ScreenUpdating = False
'Set the range with Formulas that you want to check
Set FormulaRange = Me.Range("R5:R105")
On Error GoTo EndMacro:
For Each FormulaCell In FormulaRange.Cells
With FormulaCell
If IsNumeric(.Value) = True Then
MyMsg = "Incorrect Stage Complete value"
Else
If .Value = MyLimit Then
MyMsg = SentMsg
If .Offset(0, 19).Value = NotSentMsg Then
[B]Call Mail_with_outlook2[/B]
End If
Else
MyMsg = NotSentMsg
End If
End If
Application.EnableEvents = False
.Offset(0, 19).Value = MyMsg
Application.EnableEvents = True
End With
Next FormulaCell
ExitMacro:
Exit Sub
EndMacro:
Application.EnableEvents = True
MsgBox "Error occurred. Contact Keely" _
& vbLf & Err.Number _
& vbLf & Err.Description
Application.ScreenUpdating = True
End Sub