+ Reply to Thread
Results 1 to 10 of 10

macro to automatically send email when due date approaches in XL spreadsheet.

  1. #1
    Registered User
    Join Date
    03-27-2014
    Location
    York England
    MS-Off Ver
    Excel 2007
    Posts
    10

    macro to automatically send email when due date approaches in XL spreadsheet.

    Hi Guys,
    I am a total novice so please reply in the simplist terms.
    I have a spreadsheet that I would like a macro or VBA (I think) to generate an automatic email 30 days prior to a cell date being reached.
    The column that holds the dates (K) already has a formula that changes the colour depending how close the date is and I am unsure as to how that will effect things.

    Column A will hold the recipients email address whilst I would need the info in Coloumn C to be included into the subject line ie Row 3 of the attached spreadsheet would generate:

    to: A3[
    Subject: a school (C3)

    Hi
    Just a quick email to alert you that (C3) is due a Review in 30 days.

    Kind regards


    The actual workbook has six seperate "Tabs" which would all need the same code.

    Any assistance is hugely appreciated
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Hello PTSO,

    An outline of how I would try to deal with this issue. (thinking out aloud time commences here )

    I assume you are in a "standard windows / outlook environment.

    Eventually I would have a scheduled task that commences at say 01:00 each day that opens a workbook (your "sample")and then closes it.

    The work book would have an "open workbook event" that fires up when the workbook is opened. This event would process each worksheet (tab) and generate the required emails.

    I have seen many email issues, I personally have found the Ron de Bruin web site of invaluable help in this area. (http://www.rondebruin.nl/) so that is worth a look.

    An example of how to cycle through all the worksheets in a workbook (in this case making the sheets all visible) would look something like
    Please Login or Register  to view this content.
    Smarter and more experienced people in this forum would suggest using a "filter" approach to only show the items that meet the custom criteria (something like cells in col K that are = 30 days after "today"). I am an old fashioned green screen person so I would probably construct a "for loop" to process all the rows in each tab, slower but easier to understand for a novice.

    another tip, just below the input panel in the thread is a panel of "similar threads" where often you can find just the answer you are looking for (for example in this thread I see the following link http://www.excelforum.com/excel-prog...proaching.html

    I apologise if this is at too high a level but sometimes "complete novice" doesnt actually cover the knowledge level of the poster and it isnt always clear how detailed the response should be

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  3. #3
    Registered User
    Join Date
    03-27-2014
    Location
    York England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Jmac1947,
    Very many thanks for taking the time to respond. I am exactly what it says on the tin and am a complete "novice" so as you can imagine, my imagination is getting my ability into all sorts of bother.
    Much appreciate the steer though.

    Kindest regards
    PTSO

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    PTSO,

    Thanks for the rep, not really deserved I suspect as I didn't actually help all that much.

    So... the first question is how much standard formula based excel are you comfortable with (ie are you a novice excel user or only novice VBA user??)

    Have you any experience with simply recording a macro and then looking at the code that was generated or is this a "dark art" for you??

    The contributors here are all volunteers who try to help solve "road blocks" that fellow contributors are facing, generally we do not pretend to offer to build your solution for you (although like many others I have sometimes forgotten that in the "chasing of new knowledge opportunities" )

    I find that it is always good to have a very clear plan of what you are trying to do before you get sidetracked with the actual solution.

    For example, Excel can tell you what "TODAY" is, one fact. You have in col K the due date. Excel can tell you the difference between the two dates (datediff function), the site I pointed you to can show you how to email the results if the diff = 30.

    Try to do one small aspect of the puzzle at a time manually (ie try to construct a filter sequence of actions manually, when you get the right answer then try to record a macro doing exactly those commands and see what is generated) and try to progress from there.

    I am also mildly curious as to how you ended up with this task in front of you (zigged when you should have zagged is a plausible explanation in my world that I understand)

    Importantly, do you have control over the workbook, could you add a new worksheet if you needed to simply to store important information at least while trying to build your solution.

    I will try to take a further look at some aspects tomorrow (it is very close to 23:00 here and sleep is beckoning me) for you, no promises but I will try

    Jmac

  5. #5
    Registered User
    Join Date
    03-27-2014
    Location
    York England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Hello again jmac1947,
    I am a Novice VBA user, I was a novice EXCEL user although I have learnt an awful lot over the past few days. The whole coding thing still has me stumped at the moment but I am hoping another week and I will be able move slowly forward. I am exploring formulas along with tables rather than just using a spreadsheet and am well aware that I still have much to learn. I have been trying to get the conditional formatting formula working properly. It works in the example but I have no confidence with it in my actual table. This is what I am using:

    =AND(ISNUMBER(K1),K1<=TODAY()) RED
    =AND(ISNUMBER(K1),K1TODAY()<28) AMBER
    =AND(ISNUMBER(K1),K1-TODAY()<=(30*11)) GREEN

    The colours equate to the cell format and are not part of the formula (apologies if I am stating the obvious). I have access to and control of (mostly, once approved) the original spreadsheet and have as previously stated changed it. The spreadsheet is /was a record of a small part of what we do and as such I have the luxury of time as I try to drag it (and myself) into the 21st Century.

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Hi PTSO,

    I am really sorry that I haven't responded, I have been flat out like a lizard drinking the last couple of days.

    Conditional formatting for me is always a bit of "hit and miss, mostly miss " so I wouldn't be looking to use that in any solution.

    I will sketch out a high level macro solution in the next day or two so that you can see my general thrust. I do tend to be a bit "slow and methodical in my approach so hopefully you will follow my structure (I also try to add lots of comments as to what the code is trying to do as well)

    My feeling is that isn't too difficult a problem to start with

    Jmac

  7. #7
    Registered User
    Join Date
    03-27-2014
    Location
    York England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Jmac,
    Your time and effort is very much appreciated

    Kindest regards
    PTSO

  8. #8
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    PTSO,

    making excellent progress, sent you a PM to get your email address to facilitate testing.

    A couple of issues to consider....

    Is this only for exactly 30 days (or exactly any other value of days) which would imply perhaps that it is being run every day OR that the system that populates the next Col K value only does workdays OR you will miss some.

    How do you expect to deal with the coloured rows (sub group headings by the look of it, because you have merged the cells there is no col K for those rows to even test that col K has data.

    I am having a bit of a problem with filtered rows processing at the moment, hopefully that will be resolved quickly

    Jmac

  9. #9
    Registered User
    Join Date
    03-27-2014
    Location
    York England
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Hi Jmac,
    The system that updates col K is manual if that is what you meant the dates would only be workdays mon to fri. The email address of the recipient once the cell changes to Amber will be in col A. Well that's my exited intention
    If this is not the info you wanted I apologise and hope you have taken your "patience" pill today
    Kind regards
    PTSO

  10. #10
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: macro to automatically send email when due date approaches in XL spreadsheet.

    Hi PTSO,

    Take a look at the attached workbook and the macro code it contains.

    I fear I have not completely solved your problem but it should give you some idea and structure to work with.

    I have not used your conditional formatting results although I see that it is possible to filter on colours to reduce the rows shown. Filtering is something I am just starting to experiment with in other macros so I haven't included it in this one.

    (as an aside, how many rows would you expect in the real world)

    I should also say this version is testing for exactly = 30 days and would only send a single alert email on that day which is how I understand your requirement.

    A couple of explanations. You will see that a number of variables have been declared "public". This is so they can be "seen & used" across multiple "subs" in the one module. I use these to pass the details from the processing macro (PTSO_2) to the email macro (Mail_small_Text_Outlook) which actually sends the email.

    The Mail_small_Text_Outlook macro came from the excellent Ron de Bruin site and is gratefully acknowledged.

    At the moment I have it set to display the macro rather than send it, (easier for testing purposes) so you will need to alter the .Display line in the code to be a comment and the .Send to be active when you have finished testing and are ready to actually send emails.

    I have included way more comments than I would normally use in an attempt to explain what I am doing at each step.

    If you get stuck then load up a copy of your current workbook at that time and we can take a look at your problem.

    Hope this is a good start for you on your journey into the world of excel & VBA. There are many brilliant people who volunteer their time in this forum and I am constantly learning from their answers to questions.

    Good luck

    PTSO-2.xlsm

    John (aka Jmac)
    Last edited by jmac1947; 04-04-2014 at 06:27 PM. Reason: delete duplicate workbook inclusion

+ 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. Have excel automatically send an email when a date is near
    By MCCranes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2014, 09:16 AM
  2. Send email automatically before due date
    By Kara_xy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2013, 06:11 AM
  3. Excel to send Email automatically when due date is approaching
    By EugeneE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2013, 06:34 PM
  4. Automatically Send Email When Spreadsheet Been Updated
    By Bittthhhcuit in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-26-2012, 01:02 AM
  5. Automatically Send an Email with CDO at Specfic Date and Time
    By Orangeworker in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-22-2011, 12:17 PM

Tags for this Thread

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