Hi Josh
Welcome to Excel Forum. Please when asking a question such as yours supply a sample workbook rather than placing the data into the thread as it make supplying an answer easier otherwise the person offering the solution may need to recreate a workbook to reflect your data. To add a sample workbook select "Go Advanced", "Manage Attachments" and upload a sample workbook. Make sure the sample workbook contains no sensitive or private data.
Based on your explanation the following should send an email if the current date matches the date in Column A. If it does not help you then please supply a sample workbook. In this case I assume the data starts in Row 2. I have placed some comments into the code to help you where changes may need to be made depending on your workbook layout. This code will display the email - change Display to Send where indicated to just send the email.
Sub sendEmail()
Dim OutApp As Object
Dim OutMail As Object
Dim dataWs As Worksheet
On Error GoTo test_Error
'Change the following line to the sheet containing the data
Set dataWs = Worksheets("Sheet1")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
For k = 2 To dataWs.Cells(Rows.Count, "A").End(xlUp).Row
If CDate(dataWs.Range("A" & k)) = Format(Now, "dd/mm/yyyy") Then
With OutMail
.To = dataWs.Range("B" & k)
.Cc = dataWs.Range("D" & k)
.Subject = dataWs.Range("C" & k)
.Body = dataWs.Range("E" & k)
' In place of the following statement, you can use ".Send" to Send the email
.Display
'.Send
End With
End If
Next
Set OutMail = Nothing
Set OutApp = Nothing
On Error GoTo 0
Exit Sub
test_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure test of Module1"
End Sub
If you have any questions please ask.
Bookmarks