Calculating dates for subsequent years

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,392
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a table that is used for a sheet for generating quotes and every line of the quote table has a cell or column where the date is entered (This cell is A17 or column A). Then there is a cell next to it that calculates if the date is a weekday, weekend or public holiday (This cell is B17). It has the formula =IF(A17="","",IF(COUNTIF(Sheet2!G38:G48,A17),"Public Holiday",IF(WEEKDAY(A17,2)>5,"Weekend","Mon-Fri"))).

The holidays are calculated as follows. In sheet2!G39:G49, there is a list of the public holidays for the current year. Here is a list of formulas in those cells.

G36: =NOW()
G37: =YEAR(G36)
G38: =DATE(G37,1,1)
G39: =DATE(G37,1,26)
G40: =FLOOR(DAY(MINUTE(G37/38)/2+56)&"/05/"&G37,7)-34
G41:=G40-1
G42: =G40-2
G43: =G40+1
G44: =DATE(G37,4,25)
G45: =DATE(G37,6,1+7*2)-WEEKDAY(DATE(G37,6,8-2))
G46: =DATE(G37,10,1+7*1)-WEEKDAY(DATE(G37,10,8-2))
G47; =DATE(G37,12,25)
G48: =DATE(G37,12,26)

This works perfectly for calculating the date to be a public holiday in the current year but my boss wants to be able to complete a quote with dates of activities relating to the quote in a subsequent year. If I use the current cells for calculating the date, it won't work.

I need to be able to enter a line in the quote that has a date in the current year but on the next line, enter a date for the following year or any subsequent year and have it work out if the date is a public holiday, weekday or weekend.

Thanks,
Dave
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Excel 2010
AB
171-Sep-18Weekend
1825-Dec-18Public Holiday
196-Sep-18Mon-Fri
2025-Dec-19Public Holiday
Sheet2
Cell Formulas
RangeFormula
B17=IF(A17="","",IF(COUNTIF(Sheet2!$G$38:$G$60,A17),"Public Holiday",IF(WEEKDAY(A17,2)>5,"Weekend","Mon-Fri")))
B18=IF(A18="","",IF(COUNTIF(Sheet2!$G$38:$G$60,A18),"Public Holiday",IF(WEEKDAY(A18,2)>5,"Weekend","Mon-Fri")))
B19=IF(A19="","",IF(COUNTIF(Sheet2!$G$38:$G$60,A19),"Public Holiday",IF(WEEKDAY(A19,2)>5,"Weekend","Mon-Fri")))
B20=IF(A20="","",IF(COUNTIF(Sheet2!$G$38:$G$60,A20),"Public Holiday",IF(WEEKDAY(A20,2)>5,"Weekend","Mon-Fri")))


Just copy your range G37:G48 below G40 and change G49 to 2019
edit your range to G37:G60
Repeat if necessary
 
Last edited:
Upvote 0
I just worked out how I can do it. In addition to the way above, I have added the formula in H37 to be G37+1 and then just filled the year across. I have filled across about a 100 years of public holidays and updated the field that looks for the public holidays to look at the new range. I think it now goes up to column DO.
 
Upvote 0
If you are calculating holidays for the next 100 years, you may have to edit your formula for Easter.

There is a post on this forum that shows a correction as well as a UDF.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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