complex array formula

dmg2016

New Member
Joined
Jun 29, 2016
Messages
10


I have two workbooks like the ones shown below. I am looking for single formula and no vba to calculate regular time in columns d3:d9 g3:g9, i3:i9 in workbook 2 sheet 2 based on the date, ID, and the criteria listed below. I also cannot have any additional helper columns. I am have trouble incorporating the late shift criteria into the formula. I would like to use full column references where possible because the user just wants download report without having to reset the ranges each period (sumproduct would be a last resort because of calculation time based on number of records). I can setup dynamic ranges, but it is added complexity I would prefer to avoid if possible.


OT Rules: hours worked >8 or total hours per week > 40
Regular Time: Total Non exception HR worked + Vacation hr + Jury Duty hr
Exceptions: sick hr + person time hr
Late Shift: date + 1 day (ex: if(d7="+",c7+1, c7)-->1/2/16)

My formula for d3 without the late shift critera:
Code:
=if((sumifs(Sheet3!$N:$N,Sheet3!$b:$b,D$1,Sheet3!$c:$c,$C2,Sheet3!$i:$i,Sheet1!$A$2:$A$3)+sumifs(Sheet3!$t:$t,Sheet3!$b:$b,D$1,Sheet3!$c:$c,$C2))=0,0,if((sumifs(Sheet3!$N:$N,Sheet3!$b:$b,D$1,Sheet3!$c:$c,">="&$C$2,Sheet3!$c:$c,"<="&$C2,Sheet3!$i:$i,Sheet1!$A$2:$A$3)+sumifs(Sheet3!$t:$t,Sheet3!$b:$b,D$1,Sheet3!$c:$c,">="&$C$2,Sheet3!$c:$c,"<="&$C2))>40,
if(sum($D$2:d2)>=40,0,min(40-sum($D$2:d2),F$1)),min((sumifs(Sheet3!$N:$N,Sheet3!$b:$b,D$1,Sheet3!$c:$c,$C2,Sheet3!$i:$i,Sheet1!$A$2:$A$3)+sumifs(Sheet3!$t:$t,Sheet3!$b:$b,D$1,Sheet3!$c:$c,$C2)),F$1)))

It works, but does incorporate not incorporate the date +1 because of the late shift. I would appreciate any ideas on how simplify the code above or how to incorporate the late shift criteria.

Sheet 3[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]b[/TD]
[TD="align: center"]c[/TD]
[TD="align: center"]d[/TD]
[TD="align: center"]i[/TD]
[TD="align: center"]n[/TD]
[TD="align: center"]t[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]ID[/TD]
[TD="align: center"]Date[/TD]
[TD="align: center"]Late Shift[/TD]
[TD="align: center"]exception[/TD]
[TD="align: center"]total exception hours worked[/TD]
[TD="align: center"]total non exception hours[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1/1/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1/2/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"]vacation[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1/3/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"]sick[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1/4/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1/5/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1/1/16[/TD]
[TD="align: center"]+[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1/2/16[/TD]
[TD="align: center"]+[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1/3/16[/TD]
[TD="align: center"]+[/TD]
[TD="align: center"]jury duty[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]10[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1/4/16[/TD]
[TD="align: center"]+[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]10[/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1/5/16[/TD]
[TD="align: center"]+[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]10[/TD]
[/TR]
[TR]
[TD="align: center"]12[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]1/1/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"]personal time[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]13[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]1/2/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]15[/TD]
[/TR]
[TR]
[TD="align: center"]14[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]1/3/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]15[/TD]
[/TR]
[TR]
[TD="align: center"]15[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]1/4/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]15[/TD]
[/TR]
</tbody>[/TABLE]

Workbook 1 Sheet 1
[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]a[/TD]
[TD="align: center"]b[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]exception[/TD]
[TD="align: center"]count towards OT[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]vacation[/TD]
[TD="align: center"]True[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]Jury Duty[/TD]
[TD="align: center"]True[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]Sick[/TD]
[TD="align: center"]False[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]Personal Time[/TD]
[TD="align: center"]False[/TD]
[/TR]
</tbody>[/TABLE]

sheet 2
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]a[/TD]
[TD="align: center"]b[/TD]
[TD="align: center"]c[/TD]
[TD="align: center"]d[/TD]
[TD="align: center"]e[/TD]
[TD="align: center"]f[/TD]
[TD="align: center"]g[/TD]
[TD="align: center"]h[/TD]
[TD="align: center"]i[/TD]
[TD="align: center"]j[/TD]
[TD="align: center"]k[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]ID[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]HR before OT[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]HR Before OT[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]HR before OT[/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]date[/TD]
[TD="align: center"]regular time[/TD]
[TD="align: center"]OT[/TD]
[TD="align: center"]exceptions[/TD]
[TD="align: center"]regular time[/TD]
[TD="align: center"]OT[/TD]
[TD="align: center"]exceptions[/TD]
[TD="align: center"]regular time[/TD]
[TD="align: center"]Ot[/TD]
[TD="align: center"]exceptions[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/1/16[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/2/16[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/3/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/4/16[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/5/16[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/6/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/7/16[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[TD="align: center"]Total[/TD]
[TD="align: center"]32[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]8[/TD]
[TD="align: center"]40[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"][/TD]
[TD="align: center"]24[/TD]
[TD="align: center"]21[/TD]
[TD="align: center"]8[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,226,730
Messages
6,192,702
Members
453,748
Latest member
akhtarf3

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