daddyfoxuk
Board Regular
- Joined
- Nov 18, 2016
- Messages
- 68
Hi all, I am using the below code with one issue... "J" will turn to sent when "I" has reached its value and the email does send but its sending all the previous emails as well. I only need it to send as each individual cell changes and not everything that's previously changed. Any help would be fantastic! Thanks.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim FormulaRange As Range
Dim NotSentMsg As String
Dim MyMsg As String
Dim SentMsg As String
Dim MyLimit As Double
NotSentMsg = "Not Sent"
SentMsg = "Sent"
MyLimit = 200
Set FormulaRange = Me.Range("I2:I100")
On Error GoTo EndMacro:
For Each FormulaCell In FormulaRange.Cells
With FormulaCell
If IsNumeric(.Value) = False Then
MyMsg = "Not numeric"
Else
If .Value > MyLimit Then
MyMsg = SentMsg
If .Offset(0, 1).Value = SentMsg Then
Call Mail_with_outlook2
End If
Else
MyMsg = NotSentMsg
End If
End If
Application.EnableEvents = False
.Offset(0, 1).Value = MyMsg
Application.EnableEvents = True
End With
Next FormulaCell
ExitMacro:
Exit Sub
EndMacro:
Application.EnableEvents = True
MsgBox "Some Error occurred." _
& vbLf & Err.Number _
& vbLf & Err.Description
End Sub
Last edited by a moderator: