Adding text to cell if conditional formatting changes color based on what day the holiday falls on.

cbye

New Member
Joined
Feb 2, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hi, I am trying to figure out how to add text, (FH meaning Fixed Holiday) to two consecutive cells (Thanksgiving and the day after Thanksginving) that conditional formatting turns orange based on the year and day on a calendar. I have been able to do this for the other holidays similar to Thanksgiving (Memorial day and Labor day) that could fall on different days on a calendar depending on the year. I just can't figure out how to get both days to display the FH. Also, it appears that xl2bb is displaying the months as black bars. As well as the year selector.


Book1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1Vacation Days LeftOptional Holidays Left
2VVacationFHFixed HolidayOHOptinal Holiday254
3Select a Year
4 January2024
512345678910111213141516171819202122232425262728293031
6FH       FH       
7
8
9February
10123456789101112131415161718192021222324252627282912
11
12
13
14March
1512345678910111213141516171819202122232425262728293031
16
17
18
19April
201234567891011121314151617181920212223242526272829301
21
22
23
24May
2512345678910111213141516171819202122232425262728293031
26   FH   
27
28
29June
301234567891011121314151617181920212223242526272829301
31
32
33
34July
3512345678910111213141516171819202122232425262728293031
36FH
37
38
39August
4012345678910111213141516171819202122232425262728293031
41
42
43
44September
451234567891011121314151617181920212223242526272829301
46 FH      
47
48
49October
5012345678910111213141516171819202122232425262728293031
51
52
53
54November
551234567891011121314151617181920212223242526272829301
56
57
58
59December
6012345678910111213141516171819202122232425262728293031
61FH
vacation tracker
Cell Formulas
RangeFormula
X2X2=AH19-BP27
AB2AB2=AH20-BP42
B5:AF5B5=DATE(AC4,1,0)+SEQUENCE(1,31)
I6:O6I6=IF(I5=AI5, "FH", "")
P6P6=IF(P5=AO5, "FH", "")
Q6Q6=IF(Q5=AO5, "FH", "")
R6R6=IF(R5=AO5, "FH", "")
S6S6=IF(S5=AO5, "FH", "")
T6T6=IF(T5=AO5, "FH", "")
U6U6=IF(U5=AO5, "FH", "")
V6V6=IF(V5=AO5, "FH", "")
W6W6=IF(W5=AO5, "FH", "")
B10:AF10B10=DATE(AC4,2,0)+SEQUENCE(1,31)
B15:AF15B15=DATE(AC4,3,0)+SEQUENCE(1,31)
B20:AF20B20=DATE(AC4,4,0)+SEQUENCE(1,31)
B25:AF25B25=DATE(AC4,5,0)+SEQUENCE(1,31)
Y26Y26=IF(Y25=AO6, "FH", "")
Z26Z26=IF(Z25=AO6, "FH", "")
AA26AA26=IF(AA25=AO6, "FH", "")
AB26AB26=IF(E35=AO7, "FH", "")
AC26AC26=IF(AC25=AO6, "FH", "")
AD26AD26=IF(AD25=AO6, "FH", "")
AE26AE26=IF(AE25=AO6, "FH", "")
B30:AF30B30=DATE(AC4,6,0)+SEQUENCE(1,31)
B35:AF35B35=DATE(AC4,7,0)+SEQUENCE(1,31)
E36E36=IF(E35=AO7, "FH", "")
B40:AF40B40=DATE(AC4,8,0)+SEQUENCE(1,31)
B45:AF45B45=DATE(AC4,9,0)+SEQUENCE(1,31)
B46B46=IF(B45=AO8, "FH", "")
C46C46=IF(C45=AO8, "FH", "")
D46D46=IF(D45=AO8, "FH", "")
E46E46=IF(E45=AO8, "FH", "")
F46F46=IF(F45=AO8, "FH", "")
G46G46=IF(G45=AO8, "FH", "")
H46H46=IF(H45=AO8, "FH", "")
I46I46=IF(I45=AO8, "FH", "")
B50:AF50B50=DATE(AC4,10,0)+SEQUENCE(1,31)
B55:AF55B55=DATE(AC4,11,0)+SEQUENCE(1,31)
B60:AF60B60=DATE(AC4,12,0)+SEQUENCE(1,31)
Z61Z61=IF(Z60=AO11, "FH", "")
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B60:AF60Expression=WEEKDAY(B60,2)>5textNO
B55:AF55Expression=WEEKDAY(B55,2)>5textNO
B50:AF50Expression=WEEKDAY(B50,2)>5textNO
B45:AF45Expression=WEEKDAY(B45,2)>5textNO
B40:AF40Expression=WEEKDAY(B40,2)>5textNO
B35:AF35Expression=WEEKDAY(B35,2)>5textNO
B30:AF30Expression=WEEKDAY(B30,2)>5textNO
B25:AF25Expression=WEEKDAY(B25,2)>5textNO
B20:AF20Expression=WEEKDAY(B20,2)>5textNO
B15:AF15Expression=WEEKDAY(B15,2)>5textNO
B10:AF10Expression=WEEKDAY(B10,2)>5textNO
B5:AF5Expression=WEEKDAY(B5,2)>5textNO
B6:AF6,B11:AF11,B16:AF16,B21:AF21,B26:AF26,B31:AF31,B36:AF36,B41:AF41,B46:AF46,B51:AF51,B56:AF56,B61:AF61Cell Value="OH"textNO
B6:AF6,B11:AF11,B16:AF16,B21:AF21,B26:AF26,B31:AF31,B36:AF36,B41:AF41,B46:AF46,B51:AF51,B56:AF56,B61:AF61Cell Value="V"textNO
B55:AF55Expression=MONTH(B55)<>MONTH($K$55)textNO
B45:AF45Expression=MONTH(B45)<>MONTH($K$45)textNO
B30:AF30Expression=MONTH(B30)<>MONTH($K$30)textNO
B20:AF20Expression=MONTH(B20)<>MONTH($K$20)textNO
B10:AF10Expression=MONTH(B10)<>MONTH($K$10)textNO
B6:AF6Expression=ISNUMBER(VLOOKUP(B5,$AO$4:$AO$11,1,0))textNO
B11:AF11,B16:AF16,B21:AF21,B26:AF26,B36:AF36,B46:AF46,B56:AF56,B61:AF61Expression=ISNUMBER(VLOOKUP(B10,$AO$4:$AO$11,1,0))textNO
Cells with Data Validation
CellAllowCriteria
AC4:AF4List=$AG$24:$AG$46
B6:AF6List=$AG$14:$AG$17
B36:AF36List=$AG$14:$AG$17
B46:AF46List=$AG$14:$AG$17
B61:AF61List=$AG$14:$AG$17
B51:AF51List=$AG$14:$AG$17
B11:AF11List=$AG$14:$AG$17
B16:AF16List=$AG$14:$AG$17
B21:AF21List=$AG$14:$AG$17
B26:AF26List=$AG$14:$AG$17
B31:AF31List=$AG$14:$AG$17
B41:AF41List=$AG$14:$AG$17


Book1.xlsx
AKALAMANAO
3HolidayWhenDate
4New Years DayJanurary 11/1/2024
5Martin Luther King Jr. DayThe 3rd Monday in Janurary1/15/2024
6Memoral DayThe last Monday in May5/27/2024
7Independence Day4-Jul7/4/2024
8Labor DayThe first Monday in September9/2/2024
9Thanksgiving DayThe 4th Thursday in November11/28/2024
10Day after Thanksgiving DayThe 4th Friday in November11/29/2024
11Christmas Day25-Dec12/25/2024
vacation tracker
Cell Formulas
RangeFormula
AO4AO4=DATE(AC4,1,1)
AO5AO5=DATE(AC4,1,1+14+CHOOSE(WEEKDAY(DATE(AC4,1,1)),1,0,6,5,4,3,2))
AO6AO6=DATE(AC4,6,1)-WEEKDAY(DATE(AC4,6,6))
AO7AO7=DATE(AC4,7,4)
AO8AO8=DATE(AC4,9,1)+CHOOSE(WEEKDAY(DATE(AC4,9,1)),1,0,6,5,4,3,2)
AO9AO9=DATE(AC4,11,1)+21+CHOOSE(WEEKDAY(DATE(AC4,11,1)),4,3,2,1,0,6,5)
AO10AO10=DATE(AC4,11,1)+22+CHOOSE(WEEKDAY(DATE(AC4,11,1)),4,3,2,1,0,6,5)
AO11AO11=DATE(AC4,12,25)
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I am able to copy your post, reformat the black, and then paste in the XLBB correctly, you may have some other formatting issues.

Also you should get rid of the merged cells.

The day after Thanksgiving is not always the 4th Friday of November. If Nov. 1 falls on a Friday, it will be the 5th Friday.

You are using formulas to show FH but you do not have any formulas in the cells for Thanksgiving and day after Thanksgiving. You seem to be using a different formula for every month based on knowing what holiday is near that date. I would use a single formula, and use the same formula for every day.

Starting in Jan 1 (B6):
Excel Formula:
=IF(ISERROR(MATCH(B5,$AO:$AO,0)),"","FH")
Then copy to all other dates. That should solve your Thanksgiving problem. Also if you ever have to add new holidays, you just add them in AK:AO and you don't have to change any formulas.

$scratch.xlsm
BCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
54November
551234567891011121314151617181920212223242526272829301
56                           FHFH  
Sheet2
Cell Formulas
RangeFormula
B55:AF55B55=DATE(AC4,11,0)+SEQUENCE(1,31)
B56:AF56B56=IF(ISERROR(MATCH(B55,$AO:$AO,0)),"","FH")
Dynamic array formulas.
 
Upvote 0
I removed the merged cell and formatted it as Center Across Selection. The XLBB code does not handle that. Here is what it actually looks like after I changed it, which has the same appearance as the merged cells but avoids all the problems:

1703783656100.png
 
Upvote 0
Hi Jeff, thanks for taking the time to reply back. Your formula does add the FH to the cells that I need. But as you mentioned, its not always going to be on the 28th and 29th. What didn't come across when I uploaded my sheet was in the merged columns, AC4, I have a Data Validation list that I can choose a year. And based on that, I have formulas in all of my dates to choose the right day based on the year at AC4. For instance the Thanksgiving date at AO9 I have a formula to always choose the 4th Thursdays in November, =DATE(AC4,11,1)+21+CHOOSE(WEEKDAY(DATE(AC4,11,1)),4,3,2,1,0,6,5). Then based on that I have conditional formatting that will turn those dates on the calendar day the orange color. Then I had to figure out how to add the FH to all of the orange cells on the calendar. If you look at September, for Labor day, I have an IF formula that if the date cell, C45 equals the date for Labor day in AO8 then put FH in the cell otherwise "". I applied that formula to all days that Labor day can fall on for any year. And if I change the year at AC4, it dynamically changes the days on the calendar to match that year and adds the orange conditional formatting for all fixed holidays as well as adds FH to the proper date.
I'm sure there are more stream lined ways of doing this but Im still a student of Excel and am learning new things every time I try to tweak this sheet.
Back to Thanksgiving, if I only needed to do Thanksgiving day, I would do the same thing I did for Labor day. But because these days are consecutive, I can't figure out how to apply the formula to both days no matter what year it is.
 
Upvote 0
Then I had to figure out how to add the FH to all of the orange cells on the calendar.
I think that's inside out, and probably more complicated than it needs to be. You just need the right formula to put "FH" where you need it, then use conditional formatting to turn any cell containing "FH" to orange.

I'll take a deeper look at this when time permits.
 
Upvote 0
Your probably right. As I said, Im still learning. And projects like these are how I learn to make things more proficient. I don't need to tell you, in excel there is more than one way to skin a vacation calendar. Thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,143
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