Help with formula for scheduling staff

ardykav

Board Regular
Joined
Oct 18, 2015
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I need some help with a formula. In Column A I have the persons name, Column B i have the start time of a persons shift. In column C i have the end time of that shift. The shifts can be any back to back combination of 5 minutes from 7am to 8pm so there are a total of 156 possible shifts in a given day. I have created a list which names each 5 minute interval also from 1 to 156

What i want to happen is that if a shift is entered but it contradicts a shift already there then it shows up as an error. Can have this as a conditional format of a cell or an error message in Column D whichever is the easiest.

So for example:
NameShift StartShift EndError CheckDate
John Jones7am10amShift coindcides with another shift14/04/16
John Jones10am11am14/04/16
John Jones8am9amShift coindcides with another shift14/04/16

<tbody>
</tbody>


thanks in advance
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Could you be more specific, for example can you have multiple people on the same shift? A shift coincides with an other one if either the shift start or shift end is in the range of an other sheet?
 
Upvote 0
Could you be more specific, for example can you have multiple people on the same shift? A shift coincides with an other one if either the shift start or shift end is in the range of an other sheet?

Apologies I should have been clearer. So it is only when one person is scheduled to do two shifts at overlapping times. For each shift an employee is assigned to look after a certain person so I dont want to double book them for seeing 2 people at the one time.

I tried a concatenate but this didnt work when the start or end times werent exactly the same for the differing shifts.

I just dont want to double book someone if that makes sense.

So if I put someone down to work 9-12 I want a flag to be raised say if i put them down then to work at 10-11 also.
 
Upvote 0
Anyone got any ideas for this one?

Apologies I should have been clearer. So it is only when one person is scheduled to do two shifts at overlapping times. For each shift an employee is assigned to look after a certain person so I dont want to double book them for seeing 2 people at the one time.

I tried a concatenate but this didnt work when the start or end times werent exactly the same for the differing shifts.

I just dont want to double book someone if that makes sense.

So if I put someone down to work 9-12 I want a flag to be raised say if i put them down then to work at 10-11 also.
 
Upvote 0
I have a suggestion, but it's not ideal. I did it with simple numbers so you may have to transform the formula a bit : =IF(AND(MIN(INDEX($A$1:$C$11,MATCH(A1,$A$1:$A$11,0),2))>C1,MAX(INDEX($A$1:$C$11,MATCH(A1,$A$1:$A$11,0),3))<b1)," !!!="" ","").

So, I compare the finishing time (C1) with the min of the starting time for the same guy, and the starting date (B1) with the max of the finishing time for the same guy. If one of this condition is not correct, I display " !!! ".

EDIT : THIS DO NOT WORK. I keep looking...</b1),">
 
Last edited:
Upvote 0
I have a suggestion, but it's not ideal. I did it with simple numbers so you may have to transform the formula a bit : =IF(AND(MIN(INDEX($A$1:$C$11,MATCH(A1,$A$1:$A$11,0),2))>C1,MAX(INDEX($A$1:$C$11,MATCH(A1,$A$1:$A$11,0),3))<b1)," !!!="" ","").

So, I compare the finishing time (C1) with the min of the starting time for the same guy, and the starting date (B1) with the max of the finishing time for the same guy. If one of this condition is not correct, I display " !!! ".

EDIT : THIS DO NOT WORK. I keep looking...</b1),">

thanks greatly appreciated
 
Upvote 0
Ok, after a few hours looking how to solve this with VLOOKUP or INDEX or SMALL or MATCH... I finally found something that seems to work. This is what I suggest : =SUM(($B$1:$B9<$B10)*($C$1:$C9>$B10)*($A$1:$A9=$A10),($B$1:$B9<$C10)*($C$1:$C9>$C10)*($A$1:$A9=$A10),($B$1:$B9>$B10)*($C$1:$C9<$C10)*($A$1:$A9=$A10)).

In my formula, I have the name in column A, start col B, end col C. This formula goes into D10, last row of my test. This will return the sum of occurrence of at least one of the following :
- a shift above this one has a lower starting time AND a greater finish time than this starting time
- a shift above this one has a lower starting time AND a greater finish time than this finish time
- a shift above has a greater starting time than this starting time AND a lower finish time than this finish time

As you can see in the formula, there is 3 parts in the sum, corresponding to this 3 conditions. In each part, I check the condition AND the name : ($A$1:$A$9=$A10). You can for example put this formula in your last row, change the references, and extend to the top. Then you can apply a conditionnal formatting on this column (0 is OK, >0 not OK).
 
Upvote 0

Forum statistics

Threads
1,221,444
Messages
6,159,912
Members
451,601
Latest member
terrynelson55

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