Forum Discussion
Dele65
Dec 30, 2022Copper Contributor
Excel Formula
Hi I am new to this platform. am also new to excel. Kindly let me know what is wrong with this formula =SEQUENCE(52, 7, 2023). I wanted to produce 2023 calendar. thanks
PeterBartholomew1
Dec 30, 2022Silver Contributor
Just in case there is an award for the longest formula, one could have
= LET(
startDate, DATE(year, 1, 1),
endDate, EOMONTH(startDate, 11),
listDates, SEQUENCE(1 + endDate - startDate, 1, startDate),
offset, WEEKDAY(startDate, 3),
offsetDates, IF(offset, VSTACK(EXPAND("", offset, , ""), listDates), listDates),
calendar, WRAPROWS(offsetDates, 7, ""),
calendar
)
The start date is given. The end date is calculated to allow for leap years. This allows every date of the year to be generated as a single list. Because I want every week to start with a Monday, I used the weekday to offset the dates with a number of blank cells [0 was a bit of a problem]. WRAPROWS changed the list of days to a calendar display of weeks.
My objective is to generate long formulas (no 'rule of thumb' for me!) but with each line being as simple as I can make it.