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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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,575
Messages
6,173,149
Members
452,503
Latest member
AM74

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