Grabbing any two characters instead of defined.

SSr00

New Member
Joined
Jul 14, 2023
Messages
13
Office Version
  1. 2016
Platform
  1. Windows
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.

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
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKAL
101 Sep 2301020304050607080910111213141516171819202122232425262728293001
3FriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSun
4Pte 10DD75
5Pte 01DD211
6Pte 01DD210
7Pte 10DD05
8Pte 00215
9Pte 00215
10Pte 00215
11Pte 00215
12Pte 00215
13Pte 00215
14Pte 00215
15Pte 00215
Template
Cell Formulas
RangeFormula
F1F1=A1
G1:AJ1G1=F1+1
D4:D15D4=SUMPRODUCT((WEEKDAY($F$2:$AI$2,2)<6)*(F4:AI4 = "DD"))
E4:E15E4=SUMPRODUCT((WEEKDAY($F$2:$AI$2,2)>5)*(F4:AI4 = "DD"))
AK4AK4=LET(days,FILTER(F4:AJ4,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL4AL4=ROUNDDOWN((LET( days, FILTER(F4:AJ4, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK5AK5=LET(days,FILTER(F5:AJ5,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL5AL5=ROUNDDOWN((LET( days, FILTER(F5:AJ5, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK6AK6=LET(days,FILTER(F6:AJ6,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL6AL6=ROUNDDOWN((LET( days, FILTER(F6:AJ6, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK7AK7=LET(days,FILTER(F7:AJ7,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL7AL7=ROUNDDOWN((LET( days, FILTER(F7:AJ7, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK8AK8=LET(days,FILTER(F8:AJ8,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL8AL8=ROUNDDOWN((LET( days, FILTER(F8:AJ8, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK9AK9=LET(days,FILTER(F9:AJ9,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL9AL9=ROUNDDOWN((LET( days, FILTER(F9:AJ9, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK10AK10=LET(days,FILTER(F10:AJ10,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL10AL10=ROUNDDOWN((LET( days, FILTER(F10:AJ10, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK11AK11=LET(days,FILTER(F11:AJ11,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL11AL11=ROUNDDOWN((LET( days, FILTER(F11:AJ11, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK12AK12=LET(days,FILTER(F12:AJ12,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL12AL12=ROUNDDOWN((LET( days, FILTER(F12:AJ12, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK13AK13=LET(days,FILTER(F13:AJ13,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL13AL13=ROUNDDOWN((LET( days, FILTER(F13:AJ13, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK14AK14=LET(days,FILTER(F14:AJ14,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL14AL14=ROUNDDOWN((LET( days, FILTER(F14:AJ14, LEFT(F3:AJ3)="S"), maxCount, COLUMNS(days), maxCount - IFERROR(XMATCH("DD", days, 0, -1), 0) ))/2, 0)
AK15AK15=LET(days,FILTER(F15:AJ15,LEFT(F3:AJ3)<>"S"), maxCount,COLUMNS(days),maxCount-IFERROR(XMATCH("DD",days,0,-1),0))
AL15AL15=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
NameRefers ToCells
DutyRange=Template!$F$2:$AG$20D4:E15
MyRange=Template!$F$4:$J$4,Template!$M$4:$Q$4,Template!$T$4:$X$4,Template!$AA$4:$AE$4AK4:AL4, D4:E4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E4:E50Cell Value>1textNO
D4:D50Cell Value>2textNO


EDIT:
Also, the headers in AK and AL should read "Last Weekday" + "Last Weekend" respectively.
 

Attachments

  • Screenshot 2023-07-21 143438.png
    Screenshot 2023-07-21 143438.png
    25.1 KB · Views: 7
Last edited by a moderator:
My pleasure
I have been since working with the above formula whilst trying to modify it, but I still can't seem to fix one issue. The count will always be short one weekend, so for example Jan 2024, it will count 3 weekends instead of 4. So, when someone is rostered for the first weekend of a month, it won't show that because everyone who has not been rostered for that month shows as "3"

Hope that makes sense. Thanks again!
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Which formula are you talking about?
Also can you post some data that shows the problem along with the expected result.
 
Upvote 0
Duties.DoNotEdit.1 - Master.copy.xlsx
ABCDEGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAM
101 Jan 2401020304050607080910111213141516171819202122232425262728293031
2 WDWE No.WDNo.WEMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedThuFriSatSunMonTueWedLast WDLast WE
4Pte 002203
5Pte 01DD2203
6Pte 01STD2202
7Pte 01OO2201
8Pte 01DD2200
9Pte 002203
10Pte 002203
11Pte 002203
12Pte 002203
13Pte 002203
Main Gate
Cell Formulas
RangeFormula
G1G1=A1
H1:AK2H1=G1+1
G2G2=A1
D4:D13D4=SUMPRODUCT((WEEKDAY($G$2:$AJ$2,2)<6)*(G4:AJ4<>""))
E4:E13E4=SUMPRODUCT((WEEKDAY($G$2:$AJ$2,2)>5)*(G4:AJ4 <>""))
AL4:AL13AL4=NETWORKDAYS(IFNA(LOOKUP(2,1/((LEFT($G$3:$AK$3)<>"s")*(G4:AK4<>"")),$G$1:$AK$1),$G$1),$AK$1)-1
AM4:AM13AM4=FLOOR((NETWORKDAYS.INTL(IFNA(LOOKUP(2,1/((LEFT($G$3:$AK$3)="s")*(G4:AK4<>"")),$G$1:$AK$1),$G$1),$AK$1,"1111100")-1)/2,1)
Named Ranges
NameRefers ToCells
DutyRange='Main Gate'!$G$2:$AH$20D4:E13, H2
MyRange='Main Gate'!$G$4:$K$4,'Main Gate'!$N$4:$R$4,'Main Gate'!$U$4:$Y$4,'Main Gate'!$AB$4:$AF$4AL4:AM4, D4:E4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AK1Expression=COUNTA($AK$4:$AK$50)>2textNO
AK1Expression=AND(COUNTIF(AK4:AK50, "EG")>=1, COUNTIF(AK4:AK50, "LG")>=1)textNO
AJ1Expression=COUNTA($AJ$4:$AJ$50)>2textNO
AJ1Expression=AND(COUNTIF(AJ4:AJ50, "EG")>=1, COUNTIF(AJ4:AJ50, "LG")>=1)textNO
AI1Expression=COUNTA($AI$4:$AI$50)>2textNO
AI1Expression=AND(COUNTIF(AI4:AI50, "EG")>=1, COUNTIF(AI4:AI50, "LG")>=1)textNO
AH1Expression=COUNTA($AH$4:$AH$50)>2textNO
AH1Expression=AND(COUNTIF(AH4:AH50, "EG")>=1, COUNTIF(AH4:AH50, "LG")>=1)textNO
AG1Expression=COUNTA($AG$4:$AG$50)>2textNO
AG1Expression=AND(COUNTIF(AG4:AG50, "EG")>=1, COUNTIF(AG4:AG50, "LG")>=1)textNO
AF1Expression=COUNTA($AF$4:$AF$50)>2textNO
AF1Expression=AND(COUNTIF(AF4:AF50, "EG")>=1, COUNTIF(AF4:AF50, "LG")>=1)textNO
AE1Expression=COUNTA($AE$4:$AE$50)>2textNO
AE1Expression=AND(COUNTIF(AE4:AE50, "EG")>=1, COUNTIF(AE4:AE50, "LG")>=1)textNO
AD1Expression=COUNTA($AD$4:$AD$50)>2textNO
AD1Expression=AND(COUNTIF(AD4:AD50, "EG")>=1, COUNTIF(AD4:AD50, "LG")>=1)textNO
AC1Expression=COUNTA($AC$4:$AC$50)>2textNO
AC1Expression=AND(COUNTIF(AC4:AC50, "EG")>=1, COUNTIF(AC4:AC50, "LG")>=1)textNO
AB1Expression=COUNTA($AB$4:$AB$50)>2textNO
AB1Expression=AND(COUNTIF(AB4:AB50, "EG")>=1, COUNTIF(AB4:AB50, "LG")>=1)textNO
AA1Expression=COUNTA($AA$4:$AA$50)>2textNO
AA1Expression=AND(COUNTIF(AA4:AA50, "EG")>=1, COUNTIF(AA4:AA50, "LG")>=1)textNO
Z1Expression=COUNTA($Z$4:$Z$50)>2textNO
Z1Expression=AND(COUNTIF(Z4:Z50, "EG")>=1, COUNTIF(Z4:Z50, "LG")>=1)textNO
Y1Expression=COUNTA($Y$4:$Y$50)>2textNO
Y1Expression=AND(COUNTIF(Y4:Y50, "EG")>=1, COUNTIF(Y4:Y50, "LG")>=1)textNO
X1Expression=COUNTA($X$4:$X$50)>2textNO
X1Expression=AND(COUNTIF(X4:X50, "EG")>=1, COUNTIF(X4:X50, "LG")>=1)textNO
W1Expression=COUNTA($W$4:$W$50)>2textNO
W1Expression=AND(COUNTIF(W4:W50, "EG")>=1, COUNTIF(W4:W50, "LG")>=1)textNO
V1Expression=COUNTA($V$4:$V$50)>2textNO
V1Expression=AND(COUNTIF(V4:V50, "EG")>=1, COUNTIF(V4:V50, "LG")>=1)textNO
U1Expression=COUNTA($U$4:$U$50)>2textNO
U1Expression=AND(COUNTIF(U4:U50, "EG")>=1, COUNTIF(U4:U50, "LG")>=1)textNO
T1Expression=COUNTA($T$4:$T$50)>2textNO
T1Expression=AND(COUNTIF(T4:T50, "EG")>=1, COUNTIF(T4:T50, "LG")>=1)textNO
S1Expression=COUNTA($S$4:$S$50)>2textNO
S1Expression=AND(COUNTIF(S4:S50, "EG")>=1, COUNTIF(S4:S50, "LG")>=1)textNO
R1Expression=COUNTA($R$4:$R$50)>2textNO
R1Expression=AND(COUNTIF(R4:R50, "EG")>=1, COUNTIF(R4:R50, "LG")>=1)textNO
Q1Expression=COUNTA($Q$4:$Q$50)>2textNO
Q1Expression=AND(COUNTIF(Q4:Q50, "EG")>=1, COUNTIF(Q4:Q50, "LG")>=1)textNO
P1Expression=COUNTA($P$4:$P$50)>2textNO
P1Expression=AND(COUNTIF(P4:P50, "EG")>=1, COUNTIF(P4:P50, "LG")>=1)textNO
N1Expression=COUNTA($N$4:$N$50)>2textNO
O1Expression=COUNTA($O$4:$O$50)>2textNO
N1:O1Expression=AND(COUNTIF(N4:N50, "EG")>=1, COUNTIF(N4:N50, "LG")>=1)textNO
M1Expression=COUNTA($M$4:$M$50)>2textNO
M1Expression=AND(COUNTIF(M4:M50, "EG")>=1, COUNTIF(M4:M50, "LG")>=1)textNO
L1Expression=COUNTA($L$4:$L$50)>2textNO
L1Expression=AND(COUNTIF(L4:L50, "EG")>=1, COUNTIF(L4:L50, "LG")>=1)textNO
K1Expression=COUNTA($K$4:$K$50)>2textNO
K1Expression=AND(COUNTIF(K4:K50, "EG")>=1, COUNTIF(K4:K50, "LG")>=1)textNO
I1Expression=COUNTA($I$4:$I$50)>2textNO
I1Expression=AND(COUNTIF(I4:I50, "EG")>=1, COUNTIF(I4:I50, "LG")>=1)textNO
H1Expression=COUNTA($H$4:$H$50)>2textNO
H1Expression=AND(COUNTIF(H4:H50, "EG")>=1, COUNTIF(H4:H50, "LG")>=1)textNO
G1Expression=COUNTA($G$4:$G$50)>2textNO
G1Expression=AND(COUNTIF(G4:G50, "EG")>=1, COUNTIF(G4:G50, "LG")>=1)textNO
D4:F50Cell Value>2textNO


My apologies. So as can be seen in the end column "Last WE", which counts the amount of weekends since someone was rostered. It should be at 04 and not 03 as there are 4 weekends in January.
 
Upvote 0
Excel Formula:
=FLOOR((NETWORKDAYS.INTL(IFNA(LOOKUP(2,1/((LEFT($G$3:$AK$3)="s")*(G4:AK4<>"")),$G$1:$AK$1),$G$1),$AK$1,"1111100")-1)/2,1)

That is the formula in question.
 
Upvote 0
Do you have the Let function now?
 
Upvote 0
Ok, how about
Excel Formula:
=FLOOR(IFNA(NETWORKDAYS.INTL(LOOKUP(2,1/((LEFT($G$3:$AK$3)="s")*(G4:AK4<>"")),$G$1:$AK$1),$AK$1,"1111100")-1,NETWORKDAYS.INTL($G$1,$AK$1,"1111100"))/2,1)
 
Upvote 1
Solution
Ok, how about
Excel Formula:
=FLOOR(IFNA(NETWORKDAYS.INTL(LOOKUP(2,1/((LEFT($G$3:$AK$3)="s")*(G4:AK4<>"")),$G$1:$AK$1),$AK$1,"1111100")-1,NETWORKDAYS.INTL($G$1,$AK$1,"1111100"))/2,1)
I wish you could see how happy this makes me lol. Thank you so much.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 1

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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