Forum

Send email based on...
 
Notifications
Clear all

Send email based on criteria

8 Posts
2 Users
0 Reactions
135 Views
(@shina67)
Posts: 15
Active Member
Topic starter
 

Hi All,

 

I have attached a sample workbook for easy of explanation and help.The sample worksheet will always be as a pivot table.

 

If column E is not Yes I want an email sending out (I have tried Ron De Bruin method).

The tricky bit that I cannot work out is I need the email sending to the address in column F (which is the result of a vlookup & not part of the pivot table, although could be if needed).

I need the email to include the contents of Columns A,C,D with the relevant headers.

 

So what I mean is if E2 is not Yes then email [email protected],

The email should send the message " A Return To Work is needed for ", C2, " who was absent from work on ", A2, "and returned to work on " D2.Capture.JPG

 

Hope that makes sense and someone can help.

 
Posted : 06/03/2020 1:33 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Sean,

there's no workbook attached.

I wrote something similar to this just the other day

Email Pivot Table Report to Various People

If you can supply your workbook I can adapt the code for you.

To clarify : for every row in the pivot table, you want an email sent?  All at the same time?  So the macro will be triggered by, for example, clicking a button on the sheet?

regards

Phil

 
Posted : 06/03/2020 6:36 am
(@shina67)
Posts: 15
Active Member
Topic starter
 

Hi Philip,

 

Thanks for your reply.

In answer to your questions:-

For every row in the pivot that does not contain a Yes in column E I need an email sending. So if I use a slicer to filter out the column that does not contain Yes then it would leave all emails that need sending.

All emails to be sent at the same time so a button would work.

 
Posted : 06/03/2020 9:13 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Sean,

The attached workbook will send your emails.  The sample data has lots of blanks and dates that are not set so these will need to be fixed for the code to run correctly.

As it is, there's a variable in the VBA called DisplayEmail that is set to True.  This will display the email on your screen for you to check before you manually send it.  I recommend that you do this whilst you are testing things.

Once you're happy everything is working, change DisplayEmail to false and the emails will be sent without you needing to each one by hand.

Regards

Phil

 
Posted : 06/03/2020 9:48 pm
(@shina67)
Posts: 15
Active Member
Topic starter
 

Hi Phil,

That seems to work brilliantly.

What I have forgot to add in on my original post was that column D also has to have a date in it otherwise an email is generated and potentially the person is not back at work yet.

I have noticed I missed this on the original post when I test ran the code you have done.

 

Thanks in advance.

 
Posted : 07/03/2020 1:21 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Sean,

Try this.

regards

Phil

 
Posted : 09/03/2020 2:22 am
(@shina67)
Posts: 15
Active Member
Topic starter
 

Thanks a lot Phil for your help this has worked brilliantly.

 
Posted : 12/03/2020 12:50 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

no worries. 🙂

 
Posted : 12/03/2020 2:29 am
Share: