Counting consecuative shifts

kateJarvis

New Member
Joined
Feb 8, 2020
Messages
3
Office Version
  1. 2010
Hi I don't know if this is possible but I want to count the maximum number of consecutive shifts a person is doing in a roster (so I can ensure they are not doing too many in a row)
The issues are:

  1. I don't know how to do this!
  2. The roster is made up of text in the cells
  3. there is a gap between the x2 2 week blocks
  4. the zero is a letter o representing day off.
  5. on call also is considered a day off ie not counted as a consecutive shift
all of which a cannot change - (not my roster to change - just trying to make mistakes harder to miss)

An example is:

ROSTER 3 A ROSTER 3B Rosta A Number of shiftsRoster B number of shiftsMax number of shifts in a row
MoTuWeThFrSaSuMoTuWeThFrSaSu MoTuWeThFrSaSuMoTuWeThFrSaSu
23456789101112131415 FTERDO1617181920212223242526272829
MOBOMOB1PMMOBOOMOBAC-EAC-EO4PM1PM1PMN14 TH-TRTH-TRADOOOOOTH-TRTH-TRTH-TRTH-TRTH-TRTH-TRTH-TRN
10​
10​
7​
FL-TRFL-TRFL-TRFL-TROOOADOFL-TRFL-TRFL-TRFL-TR1PMO 14 OFLFLFL1PMOon call4PM4PM OAC-EMOBMOB
10​
10​
6​
GENADOGEN8MOBGENO1PMOMOBGENOOMOBMOB 14 4PM4PM4PMOMOB1PMOMOBMOBMOBAC-L4PMOO
10​
10​
5​
ACC-TRACC-TRAC-LAC-LAC-MOO1PM-TR1PM-TR1PM3PM1PMOOG14 MOBMOBADOAC-EOMOBMOB3PM3PM3PM3PMOOOG
10​
10​
7​

I cannot seem to attach an excel doc example.. sorry

Any help would be much appreciated
Thank you
Kate
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I want to count the maximum number of consecutive shifts a person is doing in a roster

I can't help you there without code, but I would suggest maybe using conditional formatting.
I'm interested in how this might be solved using formulas. Will watch and see.
 
Upvote 0
Formula to enter in AG4:
=MAX(MAX(ISNUMBER(FIND(REPT("1";ROW($B$1:$B$14));TEXTJOIN("";TRUE;IF(LEFT($A4:$N4;1)="o";0;1))))*ROW($B$1:$B$14));MAX(ISNUMBER(FIND(REPT("1";ROW($B$1:$B$14));TEXTJOIN("";TRUE;IF(LEFT($S4:$AF4;1)="o";0;1))))*ROW($B$1:$B$14)))
Confirm it with Ctrl-Shift-Enter. Link to my solution is here.

J.Ty.
 
Upvote 0
Beware my signature: probably you will have to replace ";" by "," everywhere.
 
Upvote 0
Oh, I have forgotten to tell you: you need to confirm the formula with Ctrl-Shift-Enter, unless you are using the newest Excel from Office 365.
 
Upvote 0
Thank you so much, the formula is fantastic and I would NEVER have worked it out! I have 1 issue tho my end users are excel 2010.... public gov system :/ TEXTJOIN is not available in this version... is there an alternative work around? Sorry
 
Upvote 0
I am enjoying Sunday in the nature. I will prepare a solution later today.

J.Ty.
 
Upvote 0
I have come up with the following formula:
=MAX(MAX(ISNUMBER(FIND(REPT("0",ROW($B$1:$B$14)),--(LEFT($A4,1)="o")&--(LEFT($B4,1)="o")&--(LEFT($C4,1)="o")&--(LEFT($D4,1)="o")&--(LEFT($E4,1)="o")&--(LEFT($F4,1)="o")&--(LEFT($G4,1)="o")&--(LEFT($H4,1)="o")&--(LEFT($I4,1)="o")&--(LEFT($J4,1)="o")&--(LEFT($K4,1)="o")&--(LEFT($L4,1)="o")&--(LEFT($M4,1)="o")&--(LEFT($N4,1)="o")))*ROW($B$1:$B$14)),MAX(ISNUMBER(FIND(REPT("0",ROW($B$1:$B$14)),=--(LEFT($AS,1)="o")&--(LEFT($T4,1)="o")&--(LEFT($U4,1)="o")&--(LEFT($V4,1)="o")&--(LEFT($W4,1)="o")&--(LEFT($X4,1)="o")&--(LEFT($Y4,1)="o")&--(LEFT($Z4,1)="o")&--(LEFT($AA4,1)="o")&--(LEFT($AB4,1)="o")&--(LEFT($AC4,1)="o")&--(LEFT($AD4,1)="o")&--(LEFT($AE4,1)="o")&--(LEFT($AF4,1)="o")))*ROW($B$1:$B$14)))
As you can see it is quite long. Thereofre I have changed it a little to save on length, replacin "1" with "0" in encoding of the shifts. It is ugly now but probably not much can be done about it. The online variant now includes both variants.

BTW: How does the roster work? If it is repeating every 2 weeks, there might be long sequences of shifts which begin at the end of the cycle and continue after re-starting it.
On the other hand, if you continue with roster 3B after completing roster 3A (even sometimes) it can lead to long sequences of shifts which start in 3A and continue in 3B.

J.Ty.
 
Upvote 0
My head is spinning. :)
J.Ty. Are you able to write that out as is? Or do you build it in pieces and then bring it together?
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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