+ Reply to Thread
Results 1 to 4 of 4

VBA Function to check if appointment is 2 days away or less

  1. #1
    Registered User
    Join Date
    08-17-2023
    Location
    Canada
    MS-Off Ver
    365
    Posts
    2

    Question VBA Function to check if appointment is 2 days away or less

    Hello,

    Background: I have an Excel spreadsheet that I use to track appointments with clients. We are required to send e-mail reminders to the participants 48 hours prior to their appointment. I am still new to VBA coding but have spent a lot of time on this code and have made a lot of progress. I am able to trigger the macro and it will run through the schedule and generate e-mails based on a template. It pulls the date, time, names, e-mails, converts time zones, pre-fills the e-mail fields, etc...It's about 99% done but I'm encountering an issue and cannot for the life of me figure out how to fix it. I have two functions that are designed to check if a reminder e-mail should be sent. We need to send the reminders 48 hours or less prior to the appointment. But appointments and reminders are not scheduled/sent on Saturdays and Sundays. So this check needs to skip weekends when comparing the current date to the appointment date.

    Intended Functionality:

    Monday appointments should generate a reminder starting on Thursday the week prior
    Tuesday appointments should generate a reminder starting on Friday the week prior
    Wednesday appointments should generate a reminder starting on Monday the same week
    Thursday appointments should generate a reminder starting on Tuesday the same week
    Friday appointments should generate a reminder starting on the Wednesday same week

    Issue: When I run my Macro, it mostly follows the rules I outlined above. But I seem to have an issue with the logic involving the Friday. Today, on a Thursday, if I trigger my macro. It will generate the reminder for tomorrow and for Monday as intended. BUT, it also generates a reminder for Friday the 25th which is NOT intended since that is much more than 48 hours away.

    Does anyone know what change I need to make to stop this from happening?

    Here are my functions:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,867

    Re: VBA Function to check if appointment is 2 days away or less

    [I'm B]Administrative Note:[/B]

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. As you are new I shall do it for you this time: https://forum.ozgrid.com/forum/index...54#post1261154)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-17-2023
    Location
    Canada
    MS-Off Ver
    365
    Posts
    2

    Re: VBA Function to check if appointment is 2 days away or less

    Thank you AliGW, that is good to know and I will keep that in mind in the future. This thread can be closed as it was answered on another forum. Have a great day.

  4. #4
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: VBA Function to check if appointment is 2 days away or less


+ 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. [SOLVED] How to update a Calendar Appointment that repeats every 21 days
    By WillMa in forum Excel General
    Replies: 4
    Last Post: 03-07-2021, 06:45 PM
  2. Replies: 7
    Last Post: 08-19-2019, 07:28 AM
  3. Replies: 13
    Last Post: 09-22-2016, 09:18 AM
  4. Creat, check and delete duplicate appointment from Excel to Outlook
    By lexlut in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-07-2015, 09:26 AM
  5. Check Appointment exists before saving.
    By nobox in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2010, 03:43 PM
  6. Excel function sending appointment
    By lakey13 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-08-2010, 01:46 PM
  7. shade a cell 3 days prior to an appointment date?
    By Ltat42a in forum Excel General
    Replies: 3
    Last Post: 07-07-2008, 04:37 AM

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