Distribute total working hours to three shifts

nmiskulin

New Member
Joined
May 7, 2018
Messages
4
Hi all!

I want to distribute (divide) total working hours of an employee to shifts. There are three shifts: first - from 6 AM to 2 PM, second -from 2 PM to 10 PM, and third from 10 PM to 6 AM

simple example:

- on may 7th, The employee worked from 7 AM to 7 PM, it has to be devided to 7 hours of first shift, and 5 hours of second shift.

not so simple example

- employee started work on may 7th, 7 PM and finished on may 8th at 7 AM. His working hours are: 3 hours of second shift on the may 7th, 2 hours of third shift on may 7th, 6 hours on third shift may8 th and 1 hour of first shift on may 8th.

Also, I will have to deal with the weekends and holidays, which are paid different.

How can I accomplish this? I have tried with median function, but as I understands it can not deal with everything.

Thanks a lot

Neven
 
The first step is to calculate the start and end times for each date.

If a start time exists in that row but no end time, the end time is taken as midnight. If an end time exists but no start time, the start time is taken as midnight. The formulas also require midnight in the start column to be encoded as zero, midnight in the end column to be encoded as 24.

After start and end times, are calculated the working hours are split into their proper shifts with the formulas in columns AJ:AL.


Book1
CDEFAHAIAJAKAL
6DateWork startWork endStartEnd1st2nd3rd
7114231423081
82719719750
93191924032
104707106
11510151015410
126000
Sheet1
Cell Formulas
RangeFormula
AH7=IF(($D7="")*($E7=""),"",IF($D7="",0,$D7))
AI7=IF(($D7="")*($E7=""),"",IF($E7="",24,$E7))
AJ7=IF(($AI7="")+($AH7>=14),0, IF(($AH7<=6)*($AI7>6),MIN($AI7,14)-6, IF(($AH7>=6)*($AH7< 14),MIN($AI7,14)-$AH7,0)))
AK7=IF(($AI7="")+($AH7>=22)+($AI7<14), 0, IF(($AH7<=14)*($AI7>14),MIN($AI7,22)-14, IF(($AH7>=14)*($AH7<22),MIN($AI7,22)-$AH7,0)))
AL7=IFERROR($AI7-$AH7-SUM($AJ7:$AK7),0)
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
For the hours to appear in the report in their proper columns, I added a cell, controlled with a data validation dropdown, for the user to enter the month. Another cell is reserved for the user to enter the year. A separate block of cells was reserved for the user to enter Holiday dates manually. Two helper columns were added to the spreadsheet to determine the day of the week and if the day is a holiday.


Book1
CABACADAEAF
5DateHelper Formulas
61WeekdayIsHoliday
71Enter Month11
82April21
9330
104Enter Year40
115201850
12660
137Holidays71
148Mon 2018-01-0110
159Sun 2018-04-0120
Sheet1
Cell Formulas
RangeFormula
C7=DATE($AC$11, MATCH($AC$8,$AN$7:$AN$18,0), 1)
C8=IF(MONTH(C7+1)=MONTH($C$7), C7+1, "")
AE7=IFERROR(WEEKDAY($C7),0)
AF7=--(ISNUMBER(MATCH($C7,$AC$14:$AC$28,0)))
 
Upvote 0
Formulas are used to place the shift hours in their proper columns.

The formulas for the columns not shown are similar.


Book1
CDEFGHIJKLMN
4RegularSaturdaySunday
5DateWork startWork end1st shift2nd shift3rd shift1st shift2nd shift3rd shift1st shift2nd shift3rd shift
6123456789101112
711422 8       
8271975
Sheet1
Cell Formulas
RangeFormula
F7=($AE7>1)*($AE7< 7)*($AF7<>1)*$AJ7
G7=($AE7>1)*($AE7< 7)*($AF7<>1)*$AK7
H7=($AE7>1)*($AE7< 7)*($AF7<>1)*$AL7
I7=($AE7=7)*($AF7=0)*$AJ7
J7=($AE7=7)*($AF7=0)*$AK7
K7=($AE7=7)*($AF7=0)*$AL7
L7=($AE7=1)*($AF7=0)*$AJ7
M7=($AE7=1)*($AF7=0)*$AK7
N7=($AE7=1)*($AF7=0)*$AL7
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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