+ Reply to Thread
Results 1 to 23 of 23

Send email based on deadline date

  1. #1
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Send email based on deadline date

    Hi folks,

    There seems to be a lot of similar questions in the archives here but none have been adequately solved. So, it's obviously a bit of a puzzler. I'm unable to upload any documents so I'll try to clearly explain what I'm after:

    I have an excel spreadsheet that lists tasks, who has been assigned to them, their email address and the task deadline. Column P (from row 6 down) contains the email addresses. Column Q contains the deadline dates.

    What I need is some VBA code that will email an individual to remind them that the deadline for their task is due say, in 15 days. This could just be a line in the subject saying "Your Task Deadline is Approaching. Please Review".

    So, this code should email just the person who's task is due (on that row) NOT to all addresses in the email column (column P).

    Can anyone help with this? Or will it be condemned to the archive unanswered like all the others?

    Now there's a challenge.....

    SA
    Last edited by SAsplin; 10-10-2013 at 05:35 AM.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    SA, what is your e-mail client, Outlook, Lotus Notes, G-mail etc?
    If you like my contribution click the star icon!

  3. #3
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    OllieB - we are using Outlook 2007.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    I do not have Outlook myself but the following code should work

    Please Login or Register  to view this content.

  5. #5
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    @SA,

    did you have a chance to test?

  6. #6
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    OllieB - Apologies, I was called away from my desk. Where should I post this code? When I run it I get a run-time error 13: Type Mismatch which debugs on the following line:

    Please Login or Register  to view this content.
    Some other points to consider?
    1. The spreadsheet is actually called 'Tracker' although I amended that in the code...
    2. The email addresses are vlookup formulas pulling data from another part of the sheet
    3. The deadline dates are entered as DD/MM/YYYY and the cells are set to that format.

    Many thanks for your help,

    SA

  7. #7
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Can anyone help with this?

  8. #8
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    No patience? :-)

    change the line to

    Please Login or Register  to view this content.
    If the value in column Q is a proper date the above should work, the displayed format is not relevant. That the e-mail address in column P is a formula is not relevant. The value will be picked up correctly.

  9. #9
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Ha Ha! Woken up early this morning by my children - I had little patience then - now I'm just knackered!

    Thanks for the updated code.

    Checking now..........................................................................................

  10. #10
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Ok. The code ran fine up until:

    Please Login or Register  to view this content.
    Then it debugged with run-time error 438: object doesn't support this property or method

  11. #11
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    Found the problem, mistake on my side. The corrected code is shown below

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Morning OllieB - thanks for the post - I really do appreciate your help. It's almost right, but there seems to be one issue - it seems to send out an email for each item where the date is greater than today but less than the date in column Q. i.e. it's ignoring the 15 day prompt.

  13. #13
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    the current version selects all tasks with a due date after today

    Please Login or Register  to view this content.
    and a due date before (today + 15 days).

    Please Login or Register  to view this content.
    I fail to see anything wrong with this logic

  14. #14
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    I can't explain it either - but that's what it seems to be doing. Could I ask what the "d" does in the DateAdd command?

    Also, why does this line reference column B?
    Please Login or Register  to view this content.
    I'm just trying to get my head round how this code works!

  15. #15
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    1. The "d" in the DateAdd instruction is used to specify to add 15 days (=d) to the current date (=Now). Y9ou can use this instruction to add days, months or years to a given date

    2. The B is the column that is used to determine the number of rows on the worksheet. I honestly can't remember why I chose column B. You can change it to P or Q whichever you prefer.

    with regards to the selecting the tasks for the e-mails to send, I read your original post again and I now think you only want to send a reminder when the due date is exactly 15 days away from today. IF... that is the case

    REPLACE
    Please Login or Register  to view this content.
    BY

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Yup. The idea is to send out an email exactly 15 days before the deadline date. I have changed the code as suggested above but now it doesn't send any emails. The code runs without debugging - just no emails are sent.

  17. #17
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Hold on! I've just re-pasted your original line back in and it seems to be working! Finger's crossed.

    Just one more question - and then I'll fill your reputation box up with praise - is there a way to NOT send an email if there is a value in column R. Just to throw a spanner in the works!

  18. #18
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    Of course there is.

    Replace
    Please Login or Register  to view this content.
    By
    Please Login or Register  to view this content.
    Now it will only select tasks if the due date is exactly 15 days frrom now and if there is NO value in column R on the same row

  19. #19
    Forum Contributor
    Join Date
    08-17-2009
    Location
    West Midlands
    MS-Off Ver
    Excel 2016
    Posts
    213

    Re: Send email based on deadline date

    Oh my God! It's a kind of magic! Column R is for entering the date when the task is completed, and I didn't want an email sending out if the task was already done.

    Works like a charm.

    OllieB, I prostrate myself before your genius. Many, many thanks for your time, patience and effort. I shall of course add significant reputation for you.

  20. #20
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    You are too funny

  21. #21
    Registered User
    Join Date
    10-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Send email based on deadline date

    This is a great example of automation. I was looking for exactly the same thing. I see this post is almost two years old and if you are still an active member, would you be able to answer one question.

    Is there any possibility that this logic can work without the workbook being opened. I belive that if no one opens the workbook then the macro will not run? RIGHT

    Thank you for your help in advance.

  22. #22
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Send email based on deadline date

    The code is contained in the workbook. If the workbook is not opened the code would not be executed.

    But you can create a different solution using a separate workbook to send the e-mails and schedule the daily opening of that workbook using Windows scheduler.

  23. #23
    Registered User
    Join Date
    10-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Send email based on deadline date

    Thanks Ollie. I'll use the Scheduler.
    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Send email based on date value
    By Billie Mac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2016, 07:56 AM
  2. Automatically send an email based on the value of a cell and/or trigger date
    By psn.arya in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-05-2013, 06:17 PM
  3. VBA code to send automatic emails via outlook based on deadline
    By Britny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2013, 10:08 AM
  4. excel send an email based on cell value (Date)
    By Arpanasiaworld in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2013, 07:59 PM
  5. Send email when deadline date is approaching
    By wales12345 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2008, 07:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1