+ Reply to Thread
Results 1 to 8 of 8

Date formula considering Holidays

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2010
    Posts
    6

    Date formula considering Holidays

    Hello,

    I have a formula in Excel that when the date in a field is a Monday it returns that same Monday, same thing for Tuesday. When it is a Wednesday it returns the previous Tuesday, etc.

    =IF(WEEKDAY(E2)=2,E2,IF(WEEKDAY(E2)=3,E2,IF(WEEKDAY(E2)=4,E2-1,IF(WEEKDAY(E2)=5,E2+4,IF(WEEKDAY(E2)=6,E2+3)))))

    But I would like to enter a Holiday calendar and if the result falls on one of the Holidays, I would specify in that same calendar which day I want it to be instead.

    How could I add this to my existing formula?


    Patricia

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Date formula considering Holidays

    See the attached workbook for an example.

    Maybe something like this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-20-2014
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Date formula considering Holidays

    Hello, thank you for the reply. I am checking this out. Although I have a hard time making it work. I don't understand the references in your formula to Day1, Day6 and Day 7.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Date formula considering Holidays

    In actual fact, you don't need a "Day 7" ... I was just getting carried away

    "Day 1" is a Sunday, "Day 6" should have been "Day 7" and is a Saturday. The formulas in between represent what value to return for weekdays, that is 2,3,4,5,6.

    So, the formula should be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The reason for doing it that way is that your formula returns FALSE for a weekend date. You might not list any weekend dates, so it won't matter either way. I just think it's a bit neater and will highlight any anomalies.

    The key difference is that the formula does a VLOOKUP in a table of holiday dates and, if it finds it, it returns the value in the next column. As you know the date(s) of the holiday(s), you can replace "Hol 1", "Hol 2", etc., with actual dates of your choice. If it doesn't find an entry in the lookup table, the IFERROR function kicks in and executes the original formula or the replacement provided.

    Your formula, with the VLOOKUP addition would look like this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    As you can see, it's a little longer than the alternative provided.

    The VLOOKUP in either case is using a holiday lookup table in cells M1:N5 ... but it could be anywhere. I just don't know where you want it.

    You haven't provided a sample workbook so the only thing I have to go on is the formula. I had to make up data in order to test the solution. Obviously, I don't know what your workbook and worksheet structure is like so I can't provide an "out of the box" solution.


    Regards, TMS

  5. #5
    Registered User
    Join Date
    01-20-2014
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Date formula considering Holidays

    Thank you so much !
    I am new at this forum, I didn't realise I could add a workbook.
    I have advanced with your formula.
    For the first date Aug.22.2014 it returned in column B the correct workday Aug.25.2014. Then I had to add column C to return the new date considering the Holidays.
    I was wondering if I could do these two steps but all at once, in the same column.


    Patricia
    Attached Files Attached Files

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Date formula considering Holidays

    I think this does what you want ... sorry, my formula, not yours:

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS

  7. #7
    Registered User
    Join Date
    01-20-2014
    Location
    Montreal, Quebec
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Date formula considering Holidays

    Oh My ! You are my best friend !
    This is perfect. I have learned more thanks to you. Thank you.

    Sincerely,
    Patricia

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Date formula considering Holidays

    You're welcome. Thanks for the rep.

+ 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. Replies: 6
    Last Post: 05-20-2013, 07:45 PM
  2. Replies: 2
    Last Post: 02-28-2013, 04:24 AM
  3. Replies: 5
    Last Post: 08-02-2011, 07:11 AM
  4. [SOLVED] Formula for adding days to a date excluding weekends and holidays?
    By Jake via OfficeKB.com in forum Excel General
    Replies: 2
    Last Post: 01-25-2006, 04:03 PM
  5. [SOLVED] Formula assistance (date +2 and Holidays)
    By Andre in forum Excel General
    Replies: 7
    Last Post: 09-08-2005, 02:05 PM

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