Formua to exclude weekend & Public holidays

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,566
Office Version
  1. 2021
Platform
  1. Windows
I have a date in D2 and have a formula to compute the due date at the end of the following month less one days. For eg if date in D2 is 31/07/2015 (dd/mm/yyy) , the funds to be paid 30/08/2015


Code:
 ="Funds to to be paid "&TEXT(EOMONTH(D2,1)-1,"dd/mm/yyyy")&""


I would like to amend my formula to exclude weekends and public holidays


It would be appreciated if someone could kindly assist me
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
So…this is actually a bit tricky. The main issue is the holidays - there isn't an Excel function that detects if a day is a holiday or not. Holidays are also variable by country and in the US by state. You would need to make a table of holidays and then use something like VLOOKUP to detect if the due date is on a holiday or not. And of course you would need to keep that holiday table updated. So what I have done is just address the weekend issue. If the due date falls on a saturday or sunday, the following formula will adjust the displayed date to be the very next Monday. Note that this could fall into the beginning part of the next month. However, if you need the formula to pick the prior friday it is easily adjusted and then all dates will fall in the desired month. Anyway, this should get you going. It uses the WEEKDAY function set to Saturdays=6 and Sundays=7.

=IF( WEEKDAY((EOMONTH(D2,1)-1),2)<6, "Funds to to be paid "&TEXT(EOMONTH(D2,1)-1,"dd/mm/yyyy")&"",IF( WEEKDAY((EOMONTH(D2,1)-1),2)=6, "Funds to to be paid "&TEXT(EOMONTH(D2,1)-1+2,"dd/mm/yyyy")&"","Funds to to be paid "&TEXT(EOMONTH(D2,1)-1+1,"dd/mm/yyyy")&"" )
 
Upvote 0
Use the workday function:

Code:
="Funds to to be paid "&TEXT(WORKDAY(EOMONTH(D2,1)),-1,[I]Holidays[/I]),"dd/mm/yyyy")&""

Holidays refers to a range with dates of holidays you need to type in yourself.

I hope I didn't make a mistake just typing the code out of my head.

Edit: if the last day of the month is a weekend or holdiay, you will get the last working day of that month.
 
Last edited:
Upvote 0
Thanks for your help, much appreciated

Formula works 100%

What does the , before -1 mean in this formula? ..... EOMONTH(D2,1)),-1 ....
 
Upvote 0
The -1 is the 2nd argument of WORKDAY, meaning that 1 workday must be subtracted from the date in the 1st parameter.
 
Upvote 0

Forum statistics

Threads
1,215,544
Messages
6,125,434
Members
449,223
Latest member
Narrian

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