Look up to return ONLY last entry and calculation to return only after 5 minutes

harriet60

New Member
Joined
Apr 6, 2022
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hi everyone
I need to build a new worksheet that returns only the last entry from a log sheet and to calculate overtime payments if the operator was still working 5 minutes after shift end.
I've tried a vlookup=true but that returns entries that are not the last ones in the sequence.
I've tried to upload the mini sheet but when I try and open it I get a message stating ' This file type is not supported in protective view' so I've had to upload images.
Thanks in advance for your help, as always.
 

Attachments

  • ops1.JPG
    ops1.JPG
    252.1 KB · Views: 11
  • ops2.JPG
    ops2.JPG
    108 KB · Views: 12

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
An INDEXeption formula :) At least it will work :) Ops2 B2:
Excel Formula:
=OFFSET(INDEX(INDIRECT(ADDRESS(MATCH(A2,'Ops1'!$A$3:$A$25,0),7) &":$G$25"),MATCH(TRUE,INDEX(INDIRECT(ADDRESS(MATCH(A2,'Ops1'!$A$3:$A$25,0),7) &":$G$25")="",0),0)),-1,0)
Ops2 C2:
Excel Formula:
=FLOOR(B2, "1:00")
Ops2 D2:
Excel Formula:
=IF(C2-B2>=5,C2-B2,"00:00")
 
Upvote 0
part of the issue is the merged cells on ops1. excel is returning the value in the top cell reference only.
ex: 'ops1'!A3=Joe, 'ops1'!A3=0
you can unmerge those cells and fill them in with the same name, or copy and paste as formula, or maybe add a helper column.
in my solution i added a helper column
--------------
return max date-time, subtract times.xlsm
ABCDEFGH
1operator namemachine#machine#machine track inmachine track out
2start timeend time
3JoeJoe123435491234354910/26/22 8:5910/26/22 11:19
4Joe123435491234354910/26/22 11:3410/26/22 13:04
5JoeJoe
6SusanSusan123436461234364610/26/22 9:0310/26/22 9:03
7Susan123436461234364610/26/22 9:1110/26/22 10:37
8Susan123436461234364610/26/22 10:5510/26/22 12:33
9Susan123436461234364610/26/22 13:0410/26/22 15:05
10Susan123436461234364610/26/22 15:2610/26/22 17:08
11SusanSusan
12CarlCarl123436591234365910/26/22 8:5910/26/22 14:31
13Carl123436591234365910/26/22 11:3410/26/22 17:11
14CarlCarl
15MaryMary123435791234357910/26/22 8:5910/26/22 11:02
16Mary123435791234357910/26/22 11:3410/26/22 13:29
17Mary123435791234357910/26/22 8:5910/26/22 15:53
18Mary123435791234357910/26/22 11:3410/26/22 17:01
19MaryMary
20MichaelMichael123436771234367710/26/22 8:5910/26/22 10:47
21Michael123436771234367710/26/22 11:3410/26/22 12:39
22Michael123436771234367710/26/22 8:5910/26/22 13:00
23Michael123436771234367710/26/22 8:5910/26/22 15:17
24Michael123436771234367710/26/22 11:3410/26/22 17:06
25MichaelMichael
ops1

----------------
return max date-time, subtract times.xlsm
ABCD
1end timeshift endovertime
2Joe10/26/22 13:0413:000:00
3Susan10/26/22 17:0817:000:08
4Carl10/26/22 17:1117:000:11
5Mary10/26/22 17:0117:000:00
6Michael10/26/22 17:0617:000:06
ops2
Cell Formulas
RangeFormula
B2:B6B2=MAX(IF('ops1'!$B$3:$B$25=A2,'ops1'!$H$3:$H$25))
D2:D6D2=IF(TIME(HOUR(B2),MINUTE(B2),0)-TIME(HOUR(C2),MINUTE(C2),0)>0.00347222222626442,TIME(HOUR(B2),MINUTE(B2),0)-TIME(HOUR(C2),MINUTE(C2),0),0)
 
Upvote 0
Solution
Excel Formula:
=OFFSET(INDEX(INDIRECT(ADDRESS(MATCH(A2,'Ops1'!$A$3:$A$25,0),7) &":$G$25"),MATCH(TRUE,INDEX(INDIRECT(ADDRESS(MATCH(A2,'Ops1'!$A$3:$A$25,0),7) &":$G$25")="",0),0)),-1,0)
A slightly shorter version would be:
Excel Formula:
=OFFSET(INDEX(INDIRECT("$G$"&MATCH(A2,'Ops1'!$A$3:$A$25,0) &":$G$25"),MATCH(TRUE,INDEX(INDIRECT("$G$"&MATCH(A2,'Ops1'!$A$3:$A$25,0) &":$G$25")="",0),0)),-1,0)
 
Upvote 0
An INDEXeption formula :) At least it will work :) Ops2 B2:
Excel Formula:
=OFFSET(INDEX(INDIRECT(ADDRESS(MATCH(A2,'Ops1'!$A$3:$A$25,0),7) &":$G$25"),MATCH(TRUE,INDEX(INDIRECT(ADDRESS(MATCH(A2,'Ops1'!$A$3:$A$25,0),7) &":$G$25")="",0),0)),-1,0)
Ops2 C2:
Excel Formula:
=FLOOR(B2, "1:00")
Ops2 D2:
Excel Formula:
=IF(C2-B2>=5,C2-B2,"00:00")

Thanks so much for taking the time to reply - it took a while to reposition the formulas into the work sheet but I got there! It is now working brilliantly -
 
Upvote 0
part of the issue is the merged cells on ops1. excel is returning the value in the top cell reference only.
ex: 'ops1'!A3=Joe, 'ops1'!A3=0
you can unmerge those cells and fill them in with the same name, or copy and paste as formula, or maybe add a helper column.
in my solution i added a helper column
--------------
return max date-time, subtract times.xlsm
ABCDEFGH
1operator namemachine#machine#machine track inmachine track out
2start timeend time
3JoeJoe123435491234354910/26/22 8:5910/26/22 11:19
4Joe123435491234354910/26/22 11:3410/26/22 13:04
5JoeJoe
6SusanSusan123436461234364610/26/22 9:0310/26/22 9:03
7Susan123436461234364610/26/22 9:1110/26/22 10:37
8Susan123436461234364610/26/22 10:5510/26/22 12:33
9Susan123436461234364610/26/22 13:0410/26/22 15:05
10Susan123436461234364610/26/22 15:2610/26/22 17:08
11SusanSusan
12CarlCarl123436591234365910/26/22 8:5910/26/22 14:31
13Carl123436591234365910/26/22 11:3410/26/22 17:11
14CarlCarl
15MaryMary123435791234357910/26/22 8:5910/26/22 11:02
16Mary123435791234357910/26/22 11:3410/26/22 13:29
17Mary123435791234357910/26/22 8:5910/26/22 15:53
18Mary123435791234357910/26/22 11:3410/26/22 17:01
19MaryMary
20MichaelMichael123436771234367710/26/22 8:5910/26/22 10:47
21Michael123436771234367710/26/22 11:3410/26/22 12:39
22Michael123436771234367710/26/22 8:5910/26/22 13:00
23Michael123436771234367710/26/22 8:5910/26/22 15:17
24Michael123436771234367710/26/22 11:3410/26/22 17:06
25MichaelMichael
ops1

----------------
return max date-time, subtract times.xlsm
ABCD
1end timeshift endovertime
2Joe10/26/22 13:0413:000:00
3Susan10/26/22 17:0817:000:08
4Carl10/26/22 17:1117:000:11
5Mary10/26/22 17:0117:000:00
6Michael10/26/22 17:0617:000:06
ops2
Cell Formulas
RangeFormula
B2:B6B2=MAX(IF('ops1'!$B$3:$B$25=A2,'ops1'!$H$3:$H$25))
D2:D6D2=IF(TIME(HOUR(B2),MINUTE(B2),0)-TIME(HOUR(C2),MINUTE(C2),0)>0.00347222222626442,TIME(HOUR(B2),MINUTE(B2),0)-TIME(HOUR(C2),MINUTE(C2),0),0)

Thank you also for taking the time to reply - your solution also works and I have been able to apply it to other spreadsheets so a double thanks for that - very grateful!
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,231
Members
448,951
Latest member
jennlynn

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