VBA Code to Email if a certain date is shown

bamalovell5

New Member
Joined
Oct 7, 2014
Messages
23
Hey Guys,

I am trying make a VBA code for when the date on the Reminder Date hits it send an email to the people in column R.
1730134983557.png
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi,
Was there a question or you just are asking for a full code custom made for you?

Testing is needed and many adjustement because of unknown variables but here is a start of example code;
VBA Code:
Sub EMailReminder()
Dim rng As Range
For Each rng In Range("D7:D100")
If rng = Range("$A$5").Value Then
    Dim xOutApp As Object
    Dim xOutMail As Object
    Set xOutApp = CreateObject("Outlook.Application")
    Set xOutMail = xOutApp.CreateItem(0)
    On Error Resume Next
    With xOutMail
        .Subject = "Reminder for Fixture Carts"
        .Body = "Cart #" & rng.Offset(0, -2) & "is due"
        .To = rng.Offset(0, 14).Value
        .send
    End With
    Set xOutMail = Nothing
    Set xOutApp = Nothing
Next
End Sub

Until you are done testing I suggest putting the .send line into comment to avoid sending emails :D
I use .offset to grab the cart id 2 columns prior and the email 14 columns later. You would have to adjust that 14 for the next sections to fit distance to R.
I strongly suggest you check if rng is equal to the date to avoid sending a reminder each day you try the dates. Also depending how you get the date in A5 be careful that it does not contain hours/minutes as it would mean the date would be different in A5 and in the other cells even if they look the same (trailing digits).
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,177
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top