finding first MWF of week

Skrej

Board Regular
Joined
May 31, 2013
Messages
176
Office Version
  1. 365
Platform
  1. Windows
I'm trying to figure out a formula for an attendance roster that will calculate the first M/W/F of a month. Since this particular class only meets M/W/F, I'd like to generate an attendance roster that for each month (each month on separate sheet) which finds the first day of the month that's either a M/W/F, then calculate all the subsequent M/W/F days, skipping over weekends, etc. The in the row above, calculate which day of the week that date is

Here's a partially completed example of what September 2019 would look like:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Mon[/TD]
[TD]Wed[/TD]
[TD]Friday[/TD]
[TD]Mon[/TD]
[TD]Wed[/TD]
[TD]Friday[/TD]
[TD]Mon[/TD]
[TD]Wed[/TD]
[TD]Fri[/TD]
[/TR]
[TR]
[TD]9/2[/TD]
[TD]9/4[/TD]
[TD]9/6[/TD]
[TD]9/9[/TD]
[TD]9/11[/TD]
[TD]9/13[/TD]
[TD]9/16[/TD]
[TD]9/18[/TD]
[TD]9/20[/TD]
[/TR]
</tbody>[/TABLE]

I've been playing with some formulas I've googled, but can't quite seem to get them pieced together.

thanks in advance
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
What would the full row for October 2019 look like?
 
Last edited:
Upvote 0
...finds the first day of the month that's either a M/W/F,
The following array-entered** formula should give you the date of the first day of the month that is either a Monday, Wednesday or Friday...

=MIN(DATE(A1,B1,8)-WEEKDAY(DATE(A1,B1,8-{2,4,6})))

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself.
 
Last edited:
Upvote 0
Let's assume you have a date (say, 9/1/2019), in cell A1.

Put the following formula in cell A4 and drag-copy it until you reach cell N4:

=IF(ISERR(1/(MIN(WORKDAY.INTL(EOMONTH($A$1,-1),COLUMNS($A$1:A1),{"0111111","0101111","0101011"}))<=EOMONTH($A$1,0))),"",MIN(WORKDAY.INTL(EOMONTH($A$1,-1),COLUMNS($A$1:A1),{"0111111","0101111","0101011"})))

Custom-format the fourteen cells with the formulas as m/d

Then, put the following formula in cell A3 and drag-copy it until you reach cell N3:

=TEXT(A4,"ddd")
 
Last edited:
Upvote 0
Update: here is a simpler formula for cell A4:

=IF(MIN(WORKDAY.INTL(EOMONTH($A$1,-1),COLUMNS($A$1:A1),{"0111111","0101111","0101011"}))>EOMONTH($A$1,0),"",MIN(WORKDAY.INTL(EOMONTH($A$1,-1),COLUMNS($A$1:A1),{"0111111","0101111","0101011"})))
 
Upvote 0
Another option to consider

Fist of month in A2
B1 copied across to O1
B2 stand-alone formula
C2 copied across to O2

Excel Workbook
ABCDEFGHIJKLMNO
1WedFriMonWedFriMonWedFriMonWedFriMonWed
21/10/20192-Oct-194-Oct-197-Oct-199-Oct-1911-Oct-1914-Oct-1916-Oct-1918-Oct-1921-Oct-1923-Oct-1925-Oct-1928-Oct-1930-Oct-19
List MWF



If you want to be able to put ANY date in A2, then just change B2 to

Code:
=A2-DAY(A2)+1+AGGREGATE(15,6,7-WEEKDAY(A2-DAY(A2)+2+{2,4,6}),1)
 
Last edited:
Upvote 0
What would the full row for October 2019 look like?

It would look like this (if I've read my calendar correctly...)

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Wed
[/TD]
[TD]Fri
[/TD]
[TD]Mon
[/TD]
[TD]Wed
[/TD]
[TD]Fri
[/TD]
[TD]Mon
[/TD]
[TD]Wed
[/TD]
[TD]Fri
[/TD]
[TD]Mon
[/TD]
[TD]Wed
[/TD]
[TD]Fri
[/TD]
[TD]Mon
[/TD]
[TD]Wed
[/TD]
[/TR]
[TR]
[TD]10/2
[/TD]
[TD]10/4
[/TD]
[TD]10/7
[/TD]
[TD]10/9
[/TD]
[TD]10/11
[/TD]
[TD]10/14
[/TD]
[TD]10/16
[/TD]
[TD]10/18
[/TD]
[TD]10/21
[/TD]
[TD]10/23
[/TD]
[TD]10/25
[/TD]
[TD]10/28
[/TD]
[TD]10/30
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
The following array-entered** formula should give you the date of the first day of the month that is either a Monday, Wednesday or Friday...

=MIN(DATE(A1,B1,8)-WEEKDAY(DATE(A1,B1,8-{2,4,6})))

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself.

I'm guessing I need a date in A1, but what would be in B1?
 
Upvote 0
Update: here is a simpler formula for cell A4:

=IF(MIN(WORKDAY.INTL(EOMONTH($A$1,-1),COLUMNS($A$1:A1),{"0111111","0101111","0101011"}))>EOMONTH($A$1,0),"",MIN(WORKDAY.INTL(EOMONTH($A$1,-1),COLUMNS($A$1:A1),{"0111111","0101111","0101011"})))

Thanks, this does the trick. However, I can't follow what's going on. Could you (or somebody else) sort of step through it, so I can see how to modify it for future use? For example, modify it for Tue/Thu classes. I'm guessing some of those binary looking numbers represent the days of the week.
 
Upvote 0

Forum statistics

Threads
1,223,704
Messages
6,173,984
Members
452,540
Latest member
haasro02

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