# staff schedule

#### imported_unknown

##### Active Member
I am trying to create a staff schedule. It will finally figure the hours between start and end time, and subtract .5 hour for lunch. Now I need to add another condition for those working less than 5 hours. These should not have the .5 subtracted. This is how I was doing it so far.
=IF((24*(IF(C8>D8,D8+1-C8,D8-C8))-0.5)>0,(24*(IF(C8>D8,C8+1-C8,D8-C8))-0.5),0)
Help?
Thanks.

### Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
what is C8 and D8 exactly?

This formula will not work for difference in start and end times of 24 hours or more as the formula does not know the days worked.
Formula should work since no staff will work 24 hours straight.
For work of greater than 5 hours, the formula will take .5 hours for break. 5 hours or less, no 0.5 hours for breaks are deducted.

=IF((24*(IF(C8>D8,D8+1-C8,D8-C8))-0.5)>5,(24*(IF(C8>D8,D8+1-C8,D8-C8))-0.5),24*(D8-C8))

On 2002-10-04 23:07, GLD wrote:
I am trying to create a staff schedule. It will finally figure the hours between start and end time, and subtract .5 hour for lunch. Now I need to add another condition for those working less than 5 hours. These should not have the .5 subtracted. This is how I was doing it so far.
=IF((24*(IF(C8>D8,D8+1-C8,D8-C8))-0.5)>0,(24*(IF(C8>D8,C8+1-C8,D8-C8))-0.5),0)
Help?
Thanks.

Hi GLD:

Welcome to the Board!

Try ...

=IF(((D8-C8)+(C8>D8))*24>5,((D8-C8)+(C8>D8))*24-0.5,((D8-C8)+(C8>D8))*24)

Regards!

Yogi

Replies
2
Views
233
Replies
4
Views
324
Replies
5
Views
151
Replies
7
Views
415
Replies
2
Views
78

1,221,383
Messages
6,159,540
Members
451,571
Latest member
Qwissy

### 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.

### Which adblocker are you using?

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

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