I am trying to create an Excel Macro to remind my self for all customers that have not send any update within 30 days .The code below has this problem:After i open the excel file that is related to this macro code i am testing it by putting a date that is 30 days past from today.When i do this it recognize it and sen the email right in time.The problem is that there are more cases with 30 days ago and it does not recognize them.
Any Help i would appreciate.
Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A15")) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
If Date - Target.Value = 30 Then
Dim Email_Subject As String, Email_Send_From As String, Email_Send_To As String, _
Email_Cc As String, Email_Bcc As String, Email_Body As String
Dim Mail_Object, Mail_Single
Email_Subject = "Reminder"
Email_Send_From = "example@hotmail.com"
Email_Send_To = "example@hotmail.com"
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Please remind customer "
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.to = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body & " with ID " & Target.Offset(, 1).Value & " and name " & Target.Offset(, 2).Value
.send
End With
End If
Application.EnableEvents = True
End If
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub
Any Help i would appreciate.
Thanks.
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A15")) Is Nothing And Target.Count = 1 Then
Application.EnableEvents = False
If Date - Target.Value = 30 Then
Dim Email_Subject As String, Email_Send_From As String, Email_Send_To As String, _
Email_Cc As String, Email_Bcc As String, Email_Body As String
Dim Mail_Object, Mail_Single
Email_Subject = "Reminder"
Email_Send_From = "example@hotmail.com"
Email_Send_To = "example@hotmail.com"
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Please remind customer "
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.to = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body & " with ID " & Target.Offset(, 1).Value & " and name " & Target.Offset(, 2).Value
.send
End With
End If
Application.EnableEvents = True
End If
Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub