Formula Help (Calendar) Expanded

Cybrex

New Member
Joined
Jan 21, 2023
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I posted my original question here because it aligned with what was already being discussed (I also was using [B]jtakw[/B] coding as well so it made sense to post there but it was a really old post. So I was told to start my own!)


Hey All, I'm resurrecting this post because I have a question that works off of this (as I'm using this same formula for mine, but for some reason it wouldn't copy correctly across the row so I had to manually update where to target the year for every cell, lol).

To follow up on this, the calendar we have is used for work. Specifically to track vacation days, what days people are in the office and which office and holidays. I've attached a snippet of what it looks like to help make it easier to understand what I'm looking for.

1) Is there a way to align the day of the month with the correct date. Ie. This screenshot is supposed to be Dec 2024 but for some reason the first day it's showing is a Monday, but when I look at the Calendar it shows the 1st should be a Sunday. So not sure what's happening here?

2) Is there a way to move the column coding we have for the week days/ weekends so they align with the Days of the week at the top instead of me having to copy/paste them to align.

3) The big blue bars shown on here are marked for holidays. Is there a way I can assign another sheet to Canadian holidays and they'll update those blue bars to align with the correct days of those months?
 

Attachments

  • Vacation Calendar.PNG
    Vacation Calendar.PNG
    77.6 KB · Views: 38

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You can pretty much do all that with Conditional Formatting. Put the 1st of the month in cell AH1. The cell is formatted to show just the month and year.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAH
1Vacation & Office DatesDec, 2024
2SunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueOMT
312345678910111213141516171819202122232425262728293031
4
5
6
7
8
9
10
11
12
13
14
15
Sheet6
Cell Formulas
RangeFormula
A2:AE2A2=SEQUENCE(,DAY(EOMONTH(AH1,0)),AH1)
A3:AE3A3=A2#
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:AE15Expression=MATCH(A$2,Sheet5!$B$2:$B$10,0)textNO
A4:AE15Expression=WEEKDAY(A$2,2)>5textNO


You have the 2 formulas in A2 and A3. The rest is all cell formatting or Conditional formatting. The holiday list looks like this:

Book1
AB
1Holidays
2Christmas Eve12/24/2024
3Christmas12/25/2024
4New Year's Eve12/31/2024
5
Sheet5
 
Upvote 0
If you're just concerned with the top two rows, try this:
Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1Day 1 of Calendar Month:2024-12-01
2Month:December
3Year:2024
4TRUE
5SunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTue
612345678910111213141516171819202122232425262728293031
7
8
9
10
Sheet1
Cell Formulas
RangeFormula
B2B2=B1
B3B3=B1
A4A4=WEEKDAY(A6,2)>5
A5:AE5A5=TEXT(DAY(SEQUENCE(1,DAY(EOMONTH(B1,0)),1,1)),"ddd")
A6:AE6A6=$B$1+SEQUENCE(1,DAY(EOMONTH(B1,0)),1,1)-1
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A5:AE10Expression=IF(A$6<>"",WEEKDAY(A$6,2)>5)textNO
 
Last edited:
Upvote 0
A little more detail. I used the formulas in A2 and A3 so that there would be the right number of days in the month. February would have 28 or 29 days, November 30, etc. The cells A2 to AE2 should have a custom format of ddd and the cells A3 to AE3 should have a custom format of d.

Conditional Formatting allows a cross hatching effect like in your example, but which didn't show up in my mini sheet. You can also select which conditional formatting takes precedence in case a holiday lands on a weekend by changing the order.
 
Upvote 0
A little more detail. I used the formulas in A2 and A3 so that there would be the right number of days in the month. February would have 28 or 29 days, November 30, etc. The cells A2 to AE2 should have a custom format of ddd and the cells A3 to AE3 should have a custom format of d.

Conditional Formatting allows a cross hatching effect like in your example, but which didn't show up in my mini sheet. You can also select which conditional formatting takes precedence in case a holiday lands on a weekend by changing the order.
Okay, I'm a lot worse at Excel than I thought. lol.
So I was trying on a test sheet based off the original January one (the only one that seems to want to work with the original formula's for some reason).

Breakdown on our calendar tracker
1) 12 sheets for the months each row has an employees name assigned to it with a counter to the right side for when they have marked vacation and what office they were in on what day
2) Summary page that shows the overall count for each employee based on the counters on each month
3) Employee list that is updated when someone joins or leaves the team that than can be updated to each month (has to be done manually)
4) New: Holidays page to hopefully just needs to be updated each year with the new days so the calendar will know what to mark off when the year is changed on each month

I keep getting this Spill notice, and not sure why. I thought it was originally because when I was targeting where I have the year it was a combined amount of cell's and it wasn't understanding what was there so I then just used a single cell in A1 but it still shows Spill. The second formula seems to work fine though it starts off as 0 (which I suspect its due to the #SPILL! error above).

The holiday's section I didn't really understand to where the formula's would go and any time I tried to add it to any page it would continue to try and open a document the moment I pasted it into a cell. O_o

The conditional formatting I think I get what to do. I believe I understand by selecting all the cells, for each day (once the formula's for the days are working properly have it update with, any time it says Mon to Friday change cells to "Colour" When cells show Sat and Sun change cells to cross hatching. So the condition formatting will be based on Row C6 to AG6 ?

Sorry for being a pain, but we had the basic calendar before like in the original post on here and then I went to another team for a year and when I came back someone completely butchered it so I'm trying to make it as simple as possible so when I leave the team again (and I will! lol) there will be no further confusion on how to update it. lol

If it would be easier to upload the excel file to see what I'm doing wrong I can just change out the employees names to a lot of Smiths and remove the name of the offices?
 

Attachments

  • Calendar Fails.PNG
    Calendar Fails.PNG
    111.5 KB · Views: 10
  • Calendar Holidays.PNG
    Calendar Holidays.PNG
    22.8 KB · Views: 9
Upvote 0
First, let me suggest that you check into the XL2BB tool to post your sample sheet. It makes it easier for the helpers here to work with your data. Yes, you can upload your sample worksheet (cleaned of sensitive information) to a file sharing site and post the link here if you want. But be aware that many people do not like downloading files from the internet for security reasons, so that may limit the people who can help you.

OK, given that, I think I see a few issues based on your picture. First, the SPILL error happens when a spill formula overlaps existing data. Since you left 31 columns open, that should be enough. So there's an issue with the formula. I designed the formula to use the date in the AH1 cell as the starting point. It should be the 1st of the month that you want on this sheet (month, day, year). Then I formatted the cell to just show the month and year. (That's a custom format of "mmm, yyyy".) But on your picture it only shows the year. You have the month on the left. I can adapt the formula, but where is the year saved, and where is the month saved? And what format do they have? Is the year just a number (2024)? Is the month a number (1-12), or the word spelled out ("January")?

Also, there should be NO formulas on the holidays sheet. The other 12 monthly sheets just refer to it with the Conditional Formatting. It kind of looks like you set up the Conditional Formatting for the weekends ok. (Although it doesn't seem to properly match up with the actual weekend dates for 2022. But that could be a result of the SPILL error. We need to get that resolved first.) There's one blue bar, which indicates you have the holiday CF at least partially working too.

Let's get the SPILL error fixed first. Tell me where the month and year are stored on the sheet, and what format they're in.
 
Upvote 0
First, let me suggest that you check into the XL2BB tool to post your sample sheet. It makes it easier for the helpers here to work with your data. Yes, you can upload your sample worksheet (cleaned of sensitive information) to a file sharing site and post the link here if you want. But be aware that many people do not like downloading files from the internet for security reasons, so that may limit the people who can help you.

OK, given that, I think I see a few issues based on your picture. First, the SPILL error happens when a spill formula overlaps existing data. Since you left 31 columns open, that should be enough. So there's an issue with the formula. I designed the formula to use the date in the AH1 cell as the starting point. It should be the 1st of the month that you want on this sheet (month, day, year). Then I formatted the cell to just show the month and year. (That's a custom format of "mmm, yyyy".) But on your picture it only shows the year. You have the month on the left. I can adapt the formula, but where is the year saved, and where is the month saved? And what format do they have? Is the year just a number (2024)? Is the month a number (1-12), or the word spelled out ("January")?

Also, there should be NO formulas on the holidays sheet. The other 12 monthly sheets just refer to it with the Conditional Formatting. It kind of looks like you set up the Conditional Formatting for the weekends ok. (Although it doesn't seem to properly match up with the actual weekend dates for 2022. But that could be a result of the SPILL error. We need to get that resolved first.) There's one blue bar, which indicates you have the holiday CF at least partially working too.

Let's get the SPILL error fixed first. Tell me where the month and year are stored on the sheet, and what format they're in.
Morning Eric,

That's fair, I won't upload, I don't want people just doing the work, I want to learn and understand it so next time I'll be able to fix it, or even teach someone else how to do it.

So the original design has the month on the Left side of the screen and then we've setup the year on the right. The way it used to work (till someone touched it, lol) was, simply change the year in the top right hand corner and it would know that this is month X (based on the month on the left) and then updated the days/dates accordingly. But its so broken I couldn't get it to work. Even with the January page half working, copying/pasting to the rest of the sheets and correcting the cell's would just fail. So it's pretty much, remove formula's and put in better ones so this doesn't happen again.

Ah! I understand the holidays now, I'll leave that till the last. Conditional Formatting is pretty easy at this point for me now. Once I've got the actual mess fixed that'll be a walk in the park. lol.
 
Upvote 0
OK, if the month (spelled out) is in B4, and the year (year only) is in AH4, then try this:

Book1 (version 1).xlsb
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJ
1
2
3Vacation & Office Dates
4JanuaryMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWed2024
512345678910111213141516171819202122232425262728293031OMT
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Sheet6
Cell Formulas
RangeFormula
C4:AG4C4=LET(d,DATEVALUE(B4&" 1, "&AH4),SEQUENCE(,DAY(EOMONTH(d,0)),d))
C5:AG5C5=C4#
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C6:AG23Expression=MATCH(C$4,Holidays!$B$3:$B$11,0)textYES
C6:AG23Expression=(C$4>0)*(WEEKDAY(C$4,2)>5)textNO


The custom formatting in C4:AG4 and C5:AG5 is the same as in my previous post. Let us know how this works.
 
Upvote 0
wtf.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAK
1Vacation & In Office
2Absence TypeOMTVVacationHoliday
3Enter year:
4JanuaryVacation & Office Dates2022
5#SPILL!#VALUE!#######################################################################################
6Employee Name02345678910111213141516171819202122232425262728293031OMTV
70000
8V0001
Sheet1
Cell Formulas
RangeFormula
C5:AG5C5=LET(d,DATEVALUE(B4&" 1, "&AH4),SEQUENCE(,DAY(EOMONTH(d,0)),d))
AH7:AH8AH7=COUNTIF('C:\Users\e87111\Desktop\[Vacation & In Office Location 2022.xlsx]Jan'!$C7:$AG7,"O")
AI7:AI8AI7=COUNTIF('C:\Users\e87111\Desktop\[Vacation & In Office Location 2022.xlsx]Jan'!$C7:$AG7,"M")
AJ7:AJ8AJ7=COUNTIF('C:\Users\e87111\Desktop\[Vacation & In Office Location 2022.xlsx]Jan'!$C7:$AG7,"T")
AK7:AK8AK7=COUNTIF('C:\Users\e87111\Desktop\[Vacation & In Office Location 2022.xlsx]Jan'!$C7:$AG7,"V")
Named Ranges
NameRefers ToCells
MonthName=Sheet1!$B$4C5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C7:AG23Cell Valuecontains "V"textNO
AG7:AG23Expression=AG7=""textYES
AG7:AG23Expression=AG7=KeyCustom2textYES
AG7:AG23Expression=AG7=KeyCustom1textYES
AG7:AG23Expression=AG7=KeySicktextYES
AG7:AG23Expression=AG7=KeyPersonaltextYES
AG7:AG23Expression=AG7=KeyVacationtextYES
Z7:Z12Expression=Z7=""textYES
Z7:Z12Expression=Z7=KeyCustom2textYES
Z7:Z12Expression=Z7=KeyCustom1textYES
Z7:Z12Expression=Z7=KeySicktextYES
Z7:Z12Expression=Z7=KeyPersonaltextYES
Z7:Z12Expression=Z7=KeyVacationtextYES
L7:L12Expression=L7=""textYES
L7:L12Expression=L7=KeyCustom2textYES
L7:L12Expression=L7=KeyCustom1textYES
L7:L12Expression=L7=KeySicktextYES
L7:L12Expression=L7=KeyPersonaltextYES
L7:L12Expression=L7=KeyVacationtextYES
S7:S12Expression=S7=""textYES
S7:S12Expression=S7=KeyCustom2textYES
S7:S12Expression=S7=KeyCustom1textYES
S7:S12Expression=S7=KeySicktextYES
S7:S12Expression=S7=KeyPersonaltextYES
S7:S12Expression=S7=KeyVacationtextYES
E7:E14Expression=E7=""textYES
E7:E14Expression=E7=KeyCustom2textYES
E7:E14Expression=E7=KeyCustom1textYES
E7:E14Expression=E7=KeySicktextYES
E7:E14Expression=E7=KeyPersonaltextYES
E7:E14Expression=E7=KeyVacationtextYES
F7:G12Expression=F7=""textYES
F7:G12Expression=F7=KeyCustom2textYES
F7:G12Expression=F7=KeyCustom1textYES
F7:G12Expression=F7=KeySicktextYES
F7:G12Expression=F7=KeyPersonaltextYES
F7:G12Expression=F7=KeyVacationtextYES
M7:N11Expression=M7=""textYES
M7:N11Expression=M7=KeyCustom2textYES
M7:N11Expression=M7=KeyCustom1textYES
M7:N11Expression=M7=KeySicktextYES
M7:N11Expression=M7=KeyPersonaltextYES
M7:N11Expression=M7=KeyVacationtextYES
T7:U11Expression=T7=""textYES
T7:U11Expression=T7=KeyCustom2textYES
T7:U11Expression=T7=KeyCustom1textYES
T7:U11Expression=T7=KeySicktextYES
T7:U11Expression=T7=KeyPersonaltextYES
T7:U11Expression=T7=KeyVacationtextYES
AA7:AB11Expression=AA7=""textYES
AA7:AB11Expression=AA7=KeyCustom2textYES
AA7:AB11Expression=AA7=KeyCustom1textYES
AA7:AB11Expression=AA7=KeySicktextYES
AA7:AB11Expression=AA7=KeyPersonaltextYES
AA7:AB11Expression=AA7=KeyVacationtextYES
H7:I12,K7:K12,R7:R12,Y7:Y12,O7:P17,V7:W17,AC7:AD17Expression=H7=""textYES
H7:I12,K7:K12,R7:R12,Y7:Y12,O7:P17,V7:W17,AC7:AD17Expression=H7=KeyCustom2textYES
H7:I12,K7:K12,R7:R12,Y7:Y12,O7:P17,V7:W17,AC7:AD17Expression=H7=KeyCustom1textYES
H7:I12,K7:K12,R7:R12,Y7:Y12,O7:P17,V7:W17,AC7:AD17Expression=H7=KeySicktextYES
H7:I12,K7:K12,R7:R12,Y7:Y12,O7:P17,V7:W17,AC7:AD17Expression=H7=KeyPersonaltextYES
H7:I12,K7:K12,R7:R12,Y7:Y12,O7:P17,V7:W17,AC7:AD17Expression=H7=KeyVacationtextYES
C7:D10,J7:J17,Q7:Q17,X7:X17,AE7:AF17Expression=C7=""textYES
C7:D10,J7:J17,Q7:Q17,X7:X17,AE7:AF17Expression=C7=KeyCustom2textYES
C7:D10,J7:J17,Q7:Q17,X7:X17,AE7:AF17Expression=C7=KeyCustom1textYES
C7:D10,J7:J17,Q7:Q17,X7:X17,AE7:AF17Expression=C7=KeySicktextYES
C7:D10,J7:J17,Q7:Q17,X7:X17,AE7:AF17Expression=C7=KeyPersonaltextYES
C7:D10,J7:J17,Q7:Q17,X7:X17,AE7:AF17Expression=C7=KeyVacationtextYES
Cells with Data Validation
CellAllowCriteria
B6Any value


I just installed xl2bb because I'm lost....and I can't even get it to show the calendar....

Exact same issue as before and I even tried to rebuild the calendar from scratch without making any changes to cells and the exact same issues arise. I'm not at a complete loss. lol. I hate not understanding why its not working and not knowing how to fix it. :mad:
 

Attachments

  • wtf.PNG
    wtf.PNG
    13.3 KB · Views: 6
Upvote 0
Based on the minisheet, I found one issue. You're probably familiar with the original philosophy behind formulas. You put a formula in a cell, and it displays a value in that cell. A few years ago Microsoft came up with "Spill" formulas. These formulas can create multiple values, and these values "spill" into adjacent cells. If the adjacent cells already have something in them, you get a SPILL error. And that's what's happening here. I created a Spill formula for the C5 cell, and D5:AG5 already have something in them. So delete everything in D5:AG5, and put this formula

Excel Formula:
=LET(d,DATEVALUE(B4&" 1, "&AH4),SEQUENCE(,DAY(EOMONTH(d,0)),d))

in C5 ONLY! D5:AG5 will autofill. Do the same with the row below. Clear D6:AG6 and put

Excel Formula:
=C5#

in C6 ONLY!

Then for the formatting, select C5:AG5, right click on that range, select Format Cells, use the Number tab, click Custom, and in the Type: box put ddd and click OK. Then select C6:AG6, right click on that range, select Format Cells, use the Number tab, click Custom, and in the Type: box put d and click OK.

Let me know how that works. Then we can look at the Conditional Formatting for the weekends and holidays, which both rely on the C5 formula working right.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,814
Messages
6,181,124
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