Lookup Match Function with Variable Dates

ShaunF

Board Regular
Joined
Jan 17, 2015
Messages
54
Hi,

Hoping someone can assist with a formula to assist with a worksheet.

On SHEET 1, I have two relevant columns 'ID' and 'DATE'. For example -

ID
Date​
465260
16/08/18​
46526003/09/18
46526004/09/18
285980920/09/18
285980921/09/18
285980926/09/18
306640923/08/18
710570921/09/18
710570924/09/18
1311150927/08/18

<colgroup><col><col></colgroup><tbody>
</tbody>


On SHEET 2, I have three relevant columns 'ID' ; 'DATE' ; 'RESULT'. For example -

ID
DATE​
RESULT​
465260​
06/09/2018​
ATT​
146040008​
28/08/2018​
DNAI​
183694709​
30/09/2018​
DNAD​
259730008​
23/08/2018​
NRE​



<colgroup><col><col><col></colgroup><tbody>
</tbody>
What I am after is a formula, which tells me:

Use the ID and DATE from Sheet 1. If it finds a result in Sheet 2, where the ID is the same and the DATE is within the next 14 DAYS then return the RESULT. If no match found, then NIL.

In the above example, the second and third rows of Sheet 1 would return a result of ATT. The rest would be NIL.

Thanks,

Shaun.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If that Sheet2 data is in A1:C5, then try this, copied down.

Excel Workbook
ABC
1IDDate
246526016/08/2018 
34652603/09/2018ATT
44652604/09/2018ATT
5285980920/09/2018
6285980921/09/2018
7285980926/09/2018
8306640923/08/2018
9710570921/09/2018
10710570924/09/2018
111311150927/08/2018
Sheet1
 
Upvote 0
Hi Peter,

Thanks for your help. Much appreciated.

When I use your formula it returns an error - You've entered too many arguments for this function.

Any ideas?

Thanks.
 
Upvote 0
Hi Peter,

Thanks for your help. Much appreciated.

When I use your formula it returns an error - You've entered too many arguments for this function.

Any ideas?

Thanks.
Did you copy/paste my formula from the forum, or re-type it yourself?
Have you tried to modify it for your use? In doing that perhaps you have accidentally added/removed a "," or something?

If you click OK to that message does it highlight one particular part of the formula?

Suggest setting up a fresh workbook with only this sample data and layout and copy/paste the formula from the forum to show 'proof of concept'.

I have pasted my actual sheet so you can see that it is working here. :)
 
Last edited:
Upvote 0
In C2 of Sheet1 control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX(Sheet2!$C$2:$C$5,MIN(IF(Sheet2!$A$2:$A$5=$A2,IF(Sheet2!$B$2:$B$5<=$B2+14,ROW(Sheet2!$A$2:$C$5)-ROW(INDEX(Sheet2!$A$2:$C$5,1,1))+1,9.99E+307),9.99E+307))),"")
 
Upvote 0
Hi Peter,

Strange indeed. I have triple-checked everything. When pressing OK it highlights the '1' right towards the end of your formula.

Thanks.
 
Upvote 0
Hi Aladin,

Thanks for your help. Formula works well - however, it is bringing through results where the date is less than the date in Sheet 1. The date must be within the next 14 days (not including the actual date).

Any ideas?

Thanks,

Shaun.
 
Upvote 0
Hi Aladin,

Thanks for your help. Formula works well - however, it is bringing through results where the date is less than the date in Sheet 1. The date must be within the next 14 days (not including the actual date).

Any ideas?

Thanks,

Shaun.

Control+shift+enter:

=IFERROR(INDEX(Sheet2!$C$2:$C$5,MIN(IF(Sheet2!$A$2:$A$5=$A2,IF((Sheet2!$B$2:$B$5>$B2)*(Sheet2!$B$2:$B$5<=$B2+14),ROW(Sheet2!$A$2:$C$5)-ROW(INDEX(Sheet2!$A$2:$C$5,1,1))+1,9.99E+307),9.99E+307))),"")
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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