Fix calendar setup

Lux Aeterna

Board Regular
Joined
Aug 27, 2015
Messages
205
Office Version
  1. 2019
Platform
  1. Windows
I have a calendar setup in Excel where the first day of the month is dynamically placed in the first cell (C4). The subsequent cells (E4, G4, I4, K4, M4, O4) are populated with the following formulas. However, when the first day of the month falls on a Saturday or Sunday, the first day of the month is skipped, and I need to prevent this from happening.

The issue is that if the first day of the month is either a Saturday or Sunday, it is skipped and the formula doesn't place it correctly in the first available cell.

For example, in June 2024, cell C4 shows June 3rd, but it should be blank. Instead, cell M4 should display June 1st.

Here are the current formulas:
C4 (First Cell):
Excel Formula:
=IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)<4,DATE(YEAR($U$4),MONTH($U$4),1)+(3-WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)),"")

E4 (Second Cell):
Excel Formula:
=IF(C4="",IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=4,DATE(YEAR($U$4),MONTH($U$4),1),""),C4+1)

G4 (Third Cell):
Excel Formula:
=IF(E4="",IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=5,DATE(YEAR($U$4),MONTH($U$4),1),""),E4+1)

I4 (Fourth Cell):
Excel Formula:
=IF(G4="",IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=6,DATE(YEAR($U$4),MONTH($U$4),1),""),G4+1)

K4 (Fifth Cell):
Excel Formula:
=IF(I4="",IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7,DATE(YEAR($U$4),MONTH($U$4),1),""),I4+1)

I wrote the formulas for M4 and O4 myself, so they might be incorrect.

M4 (Sixth Cell):

Excel Formula:
=IF(K4="",IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7,DATE(YEAR($U$4),MONTH($U$4),1),""),K4+1)

O4 (Seventh Cell):
Excel Formula:
=IF(M4="",IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7,DATE(YEAR($U$4),MONTH($U$4),1),""),M4+1)


Thank you in advance!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
If you are using 16 as the return type then Saturday is 1, Sunday is 2, Monday is 3 etc.
 
Upvote 0
If you are using 16 as the return type then Saturday is 1, Sunday is 2, Monday is 3 etc.
Thanks, but I am not sure what that means and how to adjust the formulas. A forum member had helped me with that.

By the way, the &lt;4 in the first formula is <4
 
Upvote 0
It means
M4 should be
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=1
rather than
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7
and
O4 should be
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=2
rather than
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7

If C4 is <4 then it will display a value if the 1st is on a Saturday, Sunday or Monday
 
Last edited:
Upvote 0
Solution
It means
M4 should be
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=1
rather than
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7
and
O4 should be
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=2
rather than
Rich (BB code):
IF(WEEKDAY(DATE(YEAR(U4),MONTH(U4),1),16)=7
Thanks, I fixed those formulas. I think that there's still a problem in C4-K4. This is what I get (Δευτέρα means Monday). Instead, everything should be blank and M4 should be 1/6/2024.
1733686485843.png
 
Upvote 0

Forum statistics

Threads
1,225,478
Messages
6,185,228
Members
453,283
Latest member
Shortm88

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