Lookup of User ID with 2 criteria: 1) Item ID match in ranges 2) Closest date and time in the past.

Letsdoexcel

New Member
Joined
Sep 20, 2017
Messages
2
Good day, I have the following issue:

Table 1:
Column A: dateTime
Column B: Item ID

Table 2: (another worksheet)
Column D: dateTime 2
Column E: Item ID
Column F: User ID

I have to find the User ID for the related Item ID and dateTime 1 in Table 1 with the following criteria:

1. item ID from Column B = item ID from column E

2. Closest dateTime 2 to dateTime1 (dateTime2 must be always less than dateTime1, but the closest value. Basically it is the closest past date and time in relation to dateTime 2 of the same item ID.

Thank you in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
In B2 control+shift+enter, not just enter:

=INDEX($F$2:$F$10,MATCH(MAX(IF($E$2:$E$10=$B2,IF(ISNUMBER($D$2:$D$10),IF($D$2:$D$10 < $A2,$D$2:$D$10)))),IF($E$2:$E$10=$B2,IF(ISNUMBER($D$2:$D$10),IF($D$2:$D$10 < $A2,$D$2:$D$10))),0))
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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