Calendar Not Displaying Correct Number of Rows

Statto

New Member
Joined
Jul 2, 2014
Messages
6
I've made a dynamic calendar that uses just one formula. It works almost perfectly, except there are issues with some of the months. For example, February, March and November 2021 all contain the last week of the previous month, despite the start day being Tuesday. It should only display weeks where there is a day belonging to the active month.

Excel Formula:
=LET(MonthYear,$F$4&$D$4,

SEQUENCE(
ROUNDUP((DAY(EOMONTH(MonthYear,0))+WEEKDAY(MonthYear,B5))/7,0),
7,
(MonthYear)-WEEKDAY(MonthYear,B5),
1
)

)

Screenshot 2021-11-29 at 00.32.23.png


Please download the workbook at https://easyupload.io/r6n9xy.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
How about
Excel Formula:
=LET(MonthYear,$F$4&$D$4,Start,IF(TEXT(MonthYear+1,"dddd")=B4,0,WEEKDAY(MonthYear,B5)),SEQUENCE(ROUNDUP((DAY(EOMONTH(MonthYear,0))+Start)/7,0),7,(MonthYear)-Start,1))
 
Upvote 0
Unfortunately, I just realised your solution is pushing dates back by one day. For example, today is Wednesday 15th December 2021, but the calendar is showing it as Thursday.

When I add +1 to the [start] argument, the dates correctly align, but certain months still start or finish with an extra week.

2021-12-15_11-06-23.png


https://easyupload.io/pgvmhe
 
Upvote 0
How about
In B5
Excel Formula:
=SWITCH(B4,"Monday",1,"Tuesday",2,"Wednesday",3,"Thursday",4,"Friday",5,"Saturday",6,"Sunday",7)
and in C7
Excel Formula:
=LET(Start,DATE(D4,F5,1),FirstDay,WEEKDAY(Start,2),StartDay,IF(FirstDay>=B5,B5-FirstDay,B5-7-FirstDay),s,SEQUENCE(ROUNDUP((DAY(EOMONTH(Start,0))+ABS(StartDay))/7,0),7,Start+StartDay,1),s)
 
Upvote 0
Solution
You can also replace the formula in C6 with
Excel Formula:
=LEFT(TEXT(C7:I7,"ddd"))
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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