Formula/VBA calculation with Time help!

aspinray

New Member
Joined
Jan 14, 2016
Messages
16
Hi,

I have no idea what I am doing and every time I post in here you all help me out so much and I am really grateful. So here I am again!

So, I have put tables below to try and help explain. I have two reports, one that pulls dates for holidays, the date, name of the person, and if it is a full day or not. I then have another report that shows shifts for that person day to day, with start and end times and lunch times.

What is need is for the holiday report to show paid hours, minus lunch breaks, at the end of each row. The only way i think think to do this is by looking at the second report i have this is the shift report, mentioned above. So, match the persons name and date on both reports, look at start and end time, 08.00-16.00, then work out paid hours. Problem I have is everyone has different lunches and therefore the report will say 36 mins @ 4hrs 15 mins or 30 mins @ 3 hrs. As there are 1000s of requests i wondered if there was anything I could do to make this process automatic. So, the macro or formula once its matched name and date, figures the shift hours out then looks at the lunch and takes this off the total hours - so 08.00 - 16.00 is 08.00 hours minus 36 mins lunch is 07.24.

Finally, i need to only take the lunch into account if the shift is over 6 hours, otherwise the lunch doesn't get taken into account.

I am not sure how to attach excel documents, or if you can.. but below is what the reports look like.

Please let me know if you need any more information, thanks in advance!

Holiday Report
Date Period:05/06/17 - 31/12/17I need this to populate automatically
abcdefghijk
1SiteTime zoneTeamAgentDateTypeDescriptionStart TimeEnd TimeStatusPaid Hours
2NE- EnhanceGMTAB - Joe SmithName Surname05/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
3NE- EnhanceGMTAB - Joe SmithName Surname06/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
4NE- EnhanceGMTAB - Joe SmithName Surname07/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
5NE- EnhanceGMTAB - Joe SmithName Surname08/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
6NE- EnhanceGMTAB - Joe SmithName Surname09/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
7NE- EnhanceGMTAB - Joe SmithName Surname14/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
8NE- EnhanceGMTAB - Joe SmithName Surname15/06/2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted
9NE- EnhanceGMTAB - Joe SmithName Surname16/06/2017Full Day ExceptionHoliday Full DayFull DayFull DayGranted

<tbody>
</tbody>

Shift Report
Date Period:05/06/17 – 31/12/17
abcdefghij
1SiteTime zoneTeamAgentDateTypeDescriptionStart TimeEnd TimeStatus
2NE- EnhanceGMTAB - Joe SmithName Surname05/06/2017Rotating Pattern (Granted Fixed Shift)4-10hrs 36mins @ 4hrs 15 mins09:0017:00Granted
3NE- EnhanceGMTAB - Joe SmithName Surname06/06/2017Rotating Pattern (Granted Fixed Shift)4-10hrs 36mins @ 4hrs 15 mins09:0017:00Granted
4NE- EnhanceGMTAB - Joe SmithName Surname07/06/2017Rotating Pattern (Granted Fixed Shift)4-10hrs 36mins @ 4hrs 15 mins09:0017:00Granted
5NE- EnhanceGMTAB - Joe SmithName Surname08/06/2017Rotating Pattern (Granted Fixed Shift)4-10hrs 36mins @ 4hrs10:0014:00Granted
6NE- EnhanceGMTAB - Joe SmithName Surname09/06/2017Rotating Pattern (Granted Fixed Shift)4-10hrs 36mins @ 3hrs 24 mins12:0020:00Granted
7NE- EnhanceGMTAB - Joe SmithName Surname10/06/2017Rotating Pattern (Day Off)Day OffFull DayFull DayGranted
8NE- EnhanceGMTAB - Joe SmithName Surname11/06/2017Rotating Pattern (Day Off)Day OffFull DayFull DayGranted

<tbody>
</tbody>
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi,

Not VBA but with formula. Take a look at this:

Excel 2016 (Windows) 64 bit
ABCDEFGHIJK
1SiteTime zoneTeamAgentDateTypeDescriptionStart TimeEnd TimeStatusPaid Hours
2NE- EnhanceGMTAB - Joe SmithName Surname5-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted07:24
3NE- EnhanceGMTAB - Joe SmithName Surname6-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted07:24
4NE- EnhanceGMTAB - Joe SmithName Surname7-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted07:24
5NE- EnhanceGMTAB - Joe SmithName Surname8-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted00:00
6NE- EnhanceGMTAB - Joe SmithName Surname9-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted07:24
7NE- EnhanceGMTAB - Joe SmithName Surname14-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted00:00
8NE- EnhanceGMTAB - Joe SmithName Surname15-6-2017Full Day ExceptionFirst Choice Holiday Full DayFull DayFull DayGranted00:00
9NE- EnhanceGMTAB - Joe SmithName Surname16-6-2017Full Day ExceptionHoliday Full DayFull DayFull DayGranted00:00
holiday report
Cell Formulas
RangeFormula
K2{=IFERROR(IF(INDEX('Shift report'!$G$2:$G$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0))="Full Day",0,((INDEX('Shift report'!$I$2:$I$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)))-INDEX('Shift report'!$H$2:$H$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:D8&'Shift report'!$E$2:$E$8,0)))-IF(((INDEX('Shift report'!$I$2:$I$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)))-INDEX('Shift report'!$H$2:$H$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)))>(LEFT(INDEX('Shift report'!$G$2:$G$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)),1)/24),VALUE(MID(INDEX('Shift report'!$G$2:$G$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)),SEARCH("Hrs ",INDEX('Shift report'!$G$2:$G$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)),1)+4,2)),VALUE(MID(INDEX('Shift report'!$G$2:$G$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)),SEARCH("@*Hrs ",INDEX('Shift report'!$G$2:$G$8,MATCH(C2&D2&E2,'Shift report'!$C$2:$C$8&'Shift report'!$D$2:$D$8&'Shift report'!$E$2:$E$8,0)),1)+7,2)))/(60*24)),0)}
Press CTRL+SHIFT+ENTER to enter array formulas.


Beware: Cell K5 returns 0 as there's no minutes mentioned in the Shift Report cell G5 for up to 4 hrs
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,207
Members
449,214
Latest member
mr_ordinaryboy

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