How to exclude weekends & bank holidays

Baggeepants

New Member
Joined
Jan 9, 2018
Messages
8
Can the following formula be amended to exclude weekends & bank holidays? Column A is a 'Due Date' & column B is the 'Issue Date' & column C has the formula. On a separate sheet in the workbook I have a list of the Bank Holidays.

=IF(COUNT(A2,B2)=2,TEXT(B2-A2,"0 ""Day(s) Late"";0 "" Day(s) Early"";""On Time"""),"")
 

Attachments

  • Screenshot 2024-02-09 171239.jpg
    Screenshot 2024-02-09 171239.jpg
    32.3 KB · Views: 20

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Have a look at the NETWORKDAYS.INTL function. Here I've designated Saturdays and Sundays as weekend/no-work days and created a notional list of holidays that are also excluded from the day count. You may want to subtract one day, depending on when "day 1" occurs.
Book1
ABCDE
1Forecast DateIssue DateHolidays
21/8/20241/15/2024512/25/2023
31/15/202412/22/2023-141/1/2024
41/15/20241/15/202411/10/2024
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=NETWORKDAYS.INTL(A2,B2,"0000011",$E$2:$E$4)
 
Upvote 0
Thanks, although not exactly what I need (days early/late & on time required), I will give these a go as they will give a more accurate number of days.
 
Upvote 0
Oh, that's just the main idea behind the number. You can still run a test on the number (positive/negative) to determine early/late and add text to the final result. What version of Excel are you using?

Edit: The Excel version matters because there is some redundancy involved in 1) determining the number of days, 2) checking the sign of the number of days, and 3) incorporating that number in a text string...so it would be good to know whether you have access to some of the enhanced functions in Excel 365/2021.
 
Last edited:
Upvote 0
Sorry...I realized I made a mistake with the days adjustment. The NETWORKDAYS.INTL function will give 1 as a result when the start and end dates are the same--you probably want that to be 0, so I subtracted 1 from the function result. But that creates an error in some cases because negative days (early) become even more negative (which is incorrect). So I've introduced an intermediate calculation to address this (I hope). Check carefully with a few examples of early, late, on time with weekends and holidays to confirm results are as expected:
Book1
ABCDE
1Forecast DateIssue DateHolidays
21/8/20241/15/20244 Day(s) Late12/25/2023
31/15/202412/22/202313 Day(s) Early1/1/2024
41/15/20241/15/2024On Time1/10/2024
Sheet2
Cell Formulas
RangeFormula
C2:C4C2=LET(n,NETWORKDAYS.INTL(A2,B2,"0000011",$E$2:$E$4),d,n-SIGN(n),SWITCH(SIGN(d),-1,ABS(d) & " Day(s) Early",1,ABS(d) & " Day(s) Late",0,"On Time"))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top