Hi there,
So i have below code and error ("label not defined"). not sure where i need to put the Exit Sub.
appreciate your help here.
So i have below code and error ("label not defined"). not sure where i need to put the Exit Sub.
appreciate your help here.
VBA Code:
Private Sub Workbook_Open()
Dim r As Range
Dim cell As Range
Set r = Range("A2:A400")
For Each cell In r
If cell.Value - 2 = Date Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = cell.Offset(, 4).Value
Email_Send_From = "a@aaa.com"
Email_Send_To = "T@Test.com"
Email_Cc = ""
Email_Bcc = ""
Email_Body = cell.Offset(, 5).Value
'Exit Sub
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
'.send
.display
End With
End If
Next
End Sub