Employee shift counter

liampog

Active Member
Joined
Aug 3, 2010
Messages
312
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I am trying, with limited success, so set up a counter that counts whether an employee is present on shift or not, which would output as shown in the image below.

1717370256366.png



It needs to correctly handle shifts finishing at midnight (3rd shift example) and shifts that bridge midnight (4th shift example).

It also needs to be able to handle shifts that finish past the 06:00 end time of the table (5th example).

I am going to extrapolate any solutions into a 7 day per week table that counts each day.

Can anyone assist with this?

Thanks
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi @liampog

From your post I don't see what / where the data is and what / where formulas should be.

Could you please tell me, which cells should do some calculations and which cells contain data?

Regards
Pete
 
Upvote 0
Sorry, you're right it's a bit vague.

The cells with 0 and 1 would need to be formulas. The cells number 07 to 06 are times (formatted as such). The cells on the left are user input shift times (formatted as text) in 24 hour clock format.

They look at the shift entered in the left most column and determine (based upon the times at the top from 07:00 to 06:00) whether the shift time on the right means an employee is present at the time at the top.

So if you see, an employee on a 13:00 - 21:00 shift is present (shown by number 1) from 13:00 to 20:00, and then is not present from 21:00 onwards (shown by number 0).

I hope this is clearer than my original post.
 
Upvote 0
Hi @liampog
I may have figured it out...

1717838775967.png


Please paste the following formula into cell [C2]:
Excel Formula:
=IF(ISBLANK($B2),"",IF(NOT(ISNA(XMATCH(C$1*24,IF(IF(AND(NUMBERVALUE(MID($B2,LEN($B2)-4,2))>NUMBERVALUE(LEFT($B2,2)),NUMBERVALUE(LEFT($B2,2))>=0,NUMBERVALUE(LEFT($B2,2))<23,NUMBERVALUE(MID($B2,LEN($B2)-4,2))>0,NUMBERVALUE(MID($B2,LEN($B2)-4,2))<=23),NUMBERVALUE(MID($B2,LEN($B2)-4,2))-NUMBERVALUE(LEFT($B2,2)),0)<>0,SEQUENCE(1,IF(AND(NUMBERVALUE(MID($B2,LEN($B2)-4,2))>NUMBERVALUE(LEFT($B2,2)),NUMBERVALUE(LEFT($B2,2))>=0,NUMBERVALUE(LEFT($B2,2))<23,NUMBERVALUE(MID($B2,LEN($B2)-4,2))>0,NUMBERVALUE(MID($B2,LEN($B2)-4,2))<=23),NUMBERVALUE(MID($B2,LEN($B2)-4,2))-NUMBERVALUE(LEFT($B2,2)),0),NUMBERVALUE(LEFT($B2,2)),1),IF(NUMBERVALUE(MID($B2,LEN($B2)-4,2))=0,SEQUENCE(1,IF(IF(AND(NUMBERVALUE(MID($B2,LEN($B2)-4,2))>NUMBERVALUE(LEFT($B2,2)),NUMBERVALUE(LEFT($B2,2))>=0,NUMBERVALUE(LEFT($B2,2))<23,NUMBERVALUE(MID($B2,LEN($B2)-4,2))>0,NUMBERVALUE(MID($B2,LEN($B2)-4,2))<=23),NUMBERVALUE(MID($B2,LEN($B2)-4,2))-NUMBERVALUE(LEFT($B2,2)),0)=0,24-NUMBERVALUE(LEFT($B2,2)),0),NUMBERVALUE(LEFT($B2,2)),1),HSTACK(SEQUENCE(1,IF(IF(AND(NUMBERVALUE(MID($B2,LEN($B2)-4,2))>NUMBERVALUE(LEFT($B2,2)),NUMBERVALUE(LEFT($B2,2))>=0,NUMBERVALUE(LEFT($B2,2))<23,NUMBERVALUE(MID($B2,LEN($B2)-4,2))>0,NUMBERVALUE(MID($B2,LEN($B2)-4,2))<=23),NUMBERVALUE(MID($B2,LEN($B2)-4,2))-NUMBERVALUE(LEFT($B2,2)),0)=0,24-NUMBERVALUE(LEFT($B2,2)),0),NUMBERVALUE(LEFT($B2,2)),1),SEQUENCE(1,IF(IF(AND(NUMBERVALUE(MID($B2,LEN($B2)-4,2))>NUMBERVALUE(LEFT($B2,2)),NUMBERVALUE(LEFT($B2,2))>=0,NUMBERVALUE(LEFT($B2,2))<23,NUMBERVALUE(MID($B2,LEN($B2)-4,2))>0,NUMBERVALUE(MID($B2,LEN($B2)-4,2))<=23),NUMBERVALUE(MID($B2,LEN($B2)-4,2))-NUMBERVALUE(LEFT($B2,2)),0)=0,NUMBERVALUE(MID($B2,LEN($B2)-4,2)),0),0,1)))),0,1))),1,0))


The formula is huge, because I've made it up from a dozen helper cells.

Please let me know if it works and if you're OK with this long formula.
 
Upvote 0
I did this a little different than your original question, I'm not sure it will fit your requirement. Also, I had to size restrictions on the post, but, I hope the spilled array formulas will spill down. You'll just need to drag the formula in B2 over and down to complete the grid.

Cell Formulas
RangeFormula
B1:AF1B1=0/24+SEQUENCE(1,31,0,1)/24
A2:A33A2=LET(s,TEXT(SEQUENCE(32,1,0,1)/24,"h:mm"),e,TEXT(s+8/24,"h:mm"),s & " - " & e)
B2:AF13B2=LET(s,TIMEVALUE(TEXTBEFORE($A2," ")),ie,TIMEVALUE(TEXTAFTER($A2," ",2)), e,IF(ie<s,ie+1,ie), h,B$1,--AND(h>=s,h<e))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:AF33Cell Value=1textNO
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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