Automating Company Holidays on calendar

saracat2012

New Member
Joined
Jun 27, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hello again wonderful people. I have a partially automated calendar Excel file I track my time off hours in for work. I've been upgrading it a little at a time, as I learn new functionality and I've gotten to a point that seems to be very close, but is stumping me. I've extracted the relevant portion. I'm trying to get the yellow cells to auto-populate the dates when I change the year in the a reference cell (green one for this example). The array has formulas that calculate the date of specific holidays based on the year (1st section), uses a UCF to show what day the holiday falls on (2nd section), and which days the company grants for those holidays (3rd section). How do I use this information correctly to achieve the stated goal?

Bonus scenario (orange cells): The holiday given around the 4th of July changes depending on the relationship to the weekend. Ex: If 7/4 falls on a Thursday, 7/5 is given off. If it falls on a Tuesday, 7/3 is given off. This is reflected in the 3rd section of the array (the days that are given off say the name of the day). How do I make it auto-populate the holiday label (orange cells), based on the year?

As always, TIA.

Holiday sample.xlsm
ABCDEFGHIJKLMNO
1HolidayWhen20242025202620272028HolidayDate
2New Years Day1-Jan1/1/241/1/251/1/261/1/271/1/282024New Year's1/2
3MLK Jr. Day3rd Monday in Jan1/15/241/20/251/19/261/18/271/17/28MLK Jr. Day1/16
4Presidents Day3rd Monday in Feb2/19/242/17/252/16/262/15/272/21/28President's Day2/20
5Memorial DayLast Monday in May5/27/245/26/255/25/265/31/275/29/28Memorial Day 5/29
6July 3rd3-Jul7/3/247/3/257/3/267/3/277/3/283rd of July7/3
7Independence Day4-Jul7/4/247/4/257/4/267/4/277/4/28Independence Day7/4
8July 5th5-Jul7/5/247/5/257/5/267/5/277/5/28Labor Day9/4
9Labor Day1st Monday in Sept9/2/249/1/259/7/269/6/279/4/28Thanksgiving11/23
10Thanksgiving Day4th Thurs in Nov11/28/2411/27/2511/26/2611/25/2711/23/28Black Friday 11/24
11Black Friday4th Fri in Nov11/29/2411/28/2511/27/2611/26/2711/24/28Christmas Eve12/25
12Christmas EveDec. 2412/24/2412/24/2512/24/2612/24/2712/24/28Christmas Day12/26
13Christmas DayDec.2512/25/2412/25/2512/25/2612/25/2712/25/28Floating Holiday7/14
14HolidayFalls on
15New Years DayMondayWednesdayThursdayFridaySaturday
16MLK Jr. DayMondayMondayMondayMondayMonday
17Presidents DayMondayMondayMondayMondayMonday
18Memorial DayMondayMondayMondayMondayMonday
19July 3rdWednesdayThursdayFridaySaturdayMonday
20Independence DayThursdayFridaySaturdaySundayTuesday
21July 5thFridaySaturdaySundayMondayWednesday
22Labor DayMondayMondayMondayMondayMonday
23Thanksgiving DayThursdayThursdayThursdayThursdayThursday
24Black FridayFridayFridayFridayFridayFriday
25Christmas EveTuesdayWednesdayThursdayFridaySunday
26Christmas DayWednesdayThursdayFridaySaturdayMonday
27HolidayCompany holiday
28New Years DayMondayWednesdayThursdayFridayMonday
29MLK Jr. DayMondayMondayMondayMondayMonday
30Presidents DayMondayMondayMondayMondayMonday
31Memorial DayMondayMondayMondayMondayMonday
32July 3rd  FridayFridayMonday
33Independence DayThursdayFridayMonday Tuesday
34July 5thFridayMonday Monday
35Labor DayMondayMondayMondayMondayMonday
36Thanksgiving DayThursdayThursdayThursdayThursdayThursday
37Black FridayFridayFridayFridayFridayFriday
38Christmas EveTuesdayWednesdayThursdayFridayMonday
39Christmas DayWednesdayThursdayFridayFridayTuesday
40
Holidays
Cell Formulas
RangeFormula
C2:G2C2=DATE(C1,1,1)
C3:G3C3=DATE(C1,1,1)+14+CHOOSE(WEEKDAY(DATE(C1,1,1)),1,0,6,5,4,3,2)
C4:G4C4=DATE(C1,2,1)+14+CHOOSE(WEEKDAY(DATE(C1,2,1)),1,0,6,5,4,3,2)
C5:G5C5=DATE(C1,6,1)-WEEKDAY(DATE(C1,6,6))
C6:G6C6=DATE(C1,7,3)
C7:G7C7=DATE(C1,7,4)
C8:G8C8=DATE(C1,7,5)
C9:G9C9=DATE(C1,9,1)+CHOOSE(WEEKDAY(DATE(C1,9,1)),1,0,6,5,4,3,2)
C10:G10C10=DATE(C1,11,1)+21+CHOOSE(WEEKDAY(DATE(C1,11,1)),4,3,2,1,0,6,5)
C11:G11C11=DATE(C1,11,1)+22+CHOOSE(WEEKDAY(DATE(C1,11,1)),4,3,2,1,0,6,5)
C12:G12C12=DATE(C1,12,24)
C13:G13C13=DATE(C1,12,25)
C15:G26C15=mydayname(C2)
C28:G28C28=IF(mydayname(C2)="Saturday",mydayname(C2+2),IF(mydayname(C2)="Sunday",mydayname(C2+1),mydayname(C2)))
C29:G31,C35:G37C29=mydayname(C3)
C32:G32C32=IF(mydayname(C7)="Tuesday",mydayname(C6),IF(mydayname(C7)="Wednesday",mydayname(C6),IF(mydayname(C7)="Saturday",mydayname(C6),IF(mydayname(C7)="Sunday",mydayname(C6-1),""))))
C33:G33C33=IF(mydayname(C7)="Saturday","Monday",IF(mydayname(C7)="Sunday","",mydayname(C7)))
C34:G34C34=IF(mydayname(C7)="Monday", mydayname(C8), IF(mydayname(C7)="Thursday", mydayname(C8), IF(mydayname(C7)="Friday", mydayname(C8+2), IF(mydayname(C7)="Sunday", mydayname(C8), " "))))
C38:G38C38=IF(mydayname(C12)="Saturday",mydayname(C12-1),IF(mydayname(C12)="Sunday",mydayname(C12+1),mydayname(C12)))
C39:G39C39=IF(mydayname(C13)="Sunday",mydayname(C13+1),IF(mydayname(C13)="Monday",mydayname(C13+1),IF(mydayname(C13)="Saturday",mydayname(C13+6),mydayname(C13))))
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Here are formulas for the fixed-weekday-of-month holidays:
Excel Formula:
=WORKDAY.INTL((I2&"-1-1")-1,3,"0111111")   'MLK Jr. Day
=WORKDAY.INTL((I2&"-2-1")-1,3,"0111111")   'President's Day
=WORKDAY.INTL((I2&"-6-1"),-1,"0111111")   'Memorial Day
=WORKDAY.INTL((I2&"-9-1")-1,1,"0111111")   'Labor Day
=WORKDAY.INTL((I2&"-11-1")-1,4,"1110111")   'Thanksgiving
=WORKDAY.INTL((I2&"-11-1")-1,4,"1111011")   'Black Friday
To come up with formulas for fixed-date holidays, please describe how each of them is handled when they fall on Saturdays and Sundays.
 
Upvote 0
Thanks for the reply. Those work great! The rules for the fixed date holidays are different for each one. For New Year's Day, if it falls on a Saturday or Sunday, it is always the following Monday (could be as late as 1/3). For the 2 days of Christmas, they are given on the closest working day (i.e. falls on Saturday and Sunday, given on Friday and Monday) unless they fall on a Fri-Sat combo, then one is given Friday (12/24) and the other is given the following Friday (12/31), or they fall on a Sun-Mon combo, in which they are given Mon-Tues. It's convoluted, to say the least. I had to go back through my records for the last 10 years to see how they all played out.
 
Upvote 0
Here is an installment for the New Year and Christmas holidays:
Excel Formula:
=WORKDAY.INTL((I2&"-1-1")-1,1,"0000011")    'New Year Day
=WORKDAY.INTL(WORKDAY.INTL((I2&"-12-24")+1,-1,"0000010")-1,1,"0000001")    'Christmas Eve
=WORKDAY.INTL(WORKDAY.INTL((I2&"-12-25")-1,1,"1000000")-1,1,"0000001")+6*(WEEKDAY(I2&"-12-25")=7)    'Christmas Day
 
Upvote 0
Solution
I did find one issue with the Black Friday formula. In 2024, the 4th Friday is the week prior to the 4th Thursday (since the 1st is on a Friday). I was able to rectify this (I think permanently) by just referencing the Thanksgiving cell and adding 1 ("={T.G. cell} +1").
 
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,603
Members
452,658
Latest member
GStorm

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