VBA code to send email when two cells in adjacent columns are contain specific data

rimilam

New Member
Joined
Aug 7, 2020
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a code built that, upon clicking a command button, displays an email to a coworker when a cell in column P is "X". When a cell in column P is updated a date stamp is automatically entered into the adjacent cell in column Q. How do I update my code so the email displays only if the adjacent cell in Q is stamped with today's date? I'm trying to only send email notifications for the newly added Xs. I hope that makes sense. Here's a copy of my current code and a screenshot of my worksheet. TIA!!

Sub Button11_Click()
Dim OutMail As Object
Dim cell As Range

Application.ScreenUpdating = False

For Each cell In Range("P:P")
If cell.Value = "X" Then

On Error Resume Next
Set OutMail = CreateObject("Outlook.Application").CreateItem(0)
With OutMail
.To = "Harrison.holden@osteocentric.com"
.Subject = "New Tooling Requested"
.Body = "Hi there, " & vbNewLine & vbNewLine & _
"You have been assigned a new action item."
.Display
End With
On Error GoTo 0

End If
Next cell

Set OutMail = Nothing
Application.ScreenUpdating = True

End Sub

1607980719067.png
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Would recommend inserting a column to keep track whether an email has been send.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
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