I am having trouble getting the below duty roster to pick up any two characters, instead of only "DD". The goal is to count how many days since a person has last done a weekday or weekend duty from the end of the month, the input can be any two characters. Bonus points for anyone who can also figure out a way to get it to run without using the LET function, as this does not work with excel at work.
Any help at all would be hugely appreciated.
EDIT:
Also, the headers in AK and AL should read "Last Weekday" + "Last Weekend" respectively.
Any help at all would be hugely appreciated.
Excel Formula:
=LET(days,FILTER(F4:AJ4,LEFT(F3:AJ3)<>"S"),maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
Duties.DoNotEdit.1 - Maseter.xlsx | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | AE | AF | AG | AH | AI | AJ | AK | AL | |||
1 | 01 Sep 23 | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 01 | ||||||||
3 | Fri | Sat | Sun | Mon | Tue | Wed | Thu | Fri | Sat | Sun | Mon | Tue | Wed | Thu | Fri | Sat | Sun | Mon | Tue | Wed | Thu | Fri | Sat | Sun | Mon | Tue | Wed | Thu | Fri | Sat | Sun | |||||||||
4 | Pte | 1 | 0 | DD | 7 | 5 | ||||||||||||||||||||||||||||||||||
5 | Pte | 0 | 1 | DD | 21 | 1 | ||||||||||||||||||||||||||||||||||
6 | Pte | 0 | 1 | DD | 21 | 0 | ||||||||||||||||||||||||||||||||||
7 | Pte | 1 | 0 | DD | 0 | 5 | ||||||||||||||||||||||||||||||||||
8 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
9 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
10 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
11 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
12 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
13 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
14 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
15 | Pte | 0 | 0 | 21 | 5 | |||||||||||||||||||||||||||||||||||
Template |
Cell Formulas | ||
---|---|---|
Range | Formula | |
F1 | F1 | =A1 |
G1:AJ1 | G1 | =F1+1 |
D4:D15 | D4 | =SUMPRODUCT((WEEKDAY($F$2:$AI$2,2)<6)*(F4:AI4 = "DD")) |
E4:E15 | E4 | =SUMPRODUCT((WEEKDAY($F$2:$AI$2,2)>5)*(F4:AI4 = "DD")) |
AK4 | AK4 | =LET(days,FILTER(F4:AJ4,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL4 | AL4 | =ROUNDDOWN((LET( days, FILTER(F4:AJ4, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK5 | AK5 | =LET(days,FILTER(F5:AJ5,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL5 | AL5 | =ROUNDDOWN((LET( days, FILTER(F5:AJ5, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK6 | AK6 | =LET(days,FILTER(F6:AJ6,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL6 | AL6 | =ROUNDDOWN((LET( days, FILTER(F6:AJ6, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK7 | AK7 | =LET(days,FILTER(F7:AJ7,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL7 | AL7 | =ROUNDDOWN((LET( days, FILTER(F7:AJ7, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK8 | AK8 | =LET(days,FILTER(F8:AJ8,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL8 | AL8 | =ROUNDDOWN((LET( days, FILTER(F8:AJ8, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK9 | AK9 | =LET(days,FILTER(F9:AJ9,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL9 | AL9 | =ROUNDDOWN((LET( days, FILTER(F9:AJ9, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK10 | AK10 | =LET(days,FILTER(F10:AJ10,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL10 | AL10 | =ROUNDDOWN((LET( days, FILTER(F10:AJ10, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK11 | AK11 | =LET(days,FILTER(F11:AJ11,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL11 | AL11 | =ROUNDDOWN((LET( days, FILTER(F11:AJ11, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK12 | AK12 | =LET(days,FILTER(F12:AJ12,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL12 | AL12 | =ROUNDDOWN((LET( days, FILTER(F12:AJ12, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK13 | AK13 | =LET(days,FILTER(F13:AJ13,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL13 | AL13 | =ROUNDDOWN((LET( days, FILTER(F13:AJ13, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK14 | AK14 | =LET(days,FILTER(F14:AJ14,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL14 | AL14 | =ROUNDDOWN((LET( days, FILTER(F14:AJ14, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
AK15 | AK15 | =LET(days,FILTER(F15:AJ15,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0)) |
AL15 | AL15 | =ROUNDDOWN((LET( days, FILTER(F15:AJ15, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0) |
Named Ranges | ||
---|---|---|
Name | Refers To | Cells |
DutyRange | =Template!$F$2:$AG$20 | D4:E15 |
MyRange | =Template!$F$4:$J$4,Template!$M$4:$Q$4,Template!$T$4:$X$4,Template!$AA$4:$AE$4 | AK4:AL4, D4:E4 |
Cells with Conditional Formatting | ||||
---|---|---|---|---|
Cell | Condition | Cell Format | Stop If True | |
E4:E50 | Cell Value | >1 | text | NO |
D4:D50 | Cell Value | >2 | text | NO |
EDIT:
Also, the headers in AK and AL should read "Last Weekday" + "Last Weekend" respectively.
Attachments
Last edited by a moderator: