Complicated Match/Lookup in between dates formula?

jwillits

New Member
Joined
Jul 10, 2018
Messages
36
Office Version
  1. 2010
Platform
  1. Windows
Objective: I am trying to obtain a number (ID) from Table A based off of the Date and Number in Table B. What I am trying to say in my formula is that if Phone Number in Table B is equal to a Phone Number in Table A, and the Date in Table B in the same row as that Phone Number is between the Start and End Date in Table A, then I want the corresponding ID from Table A generated in the first column in Table B.

Furthermore, if the phone number matches but it does not fall between a one of the list of dates, I need it to pull the ID from the closest range of dates before it.

For instance, the last row in Table B has a Master Date of 4/22/19, however there is no date range in Table A for it, so it is pulling the ID from the date ranges of 3-26-19 to 4-1-19 because it is the closest date ranges before the master date.

Hopefully this makes sense and there is some wizard out there who can accomplish this. Multiple formulas building on each other is fine as well.





Table A

NameIDDate StartDate EndPhone Number
Apple

<tbody>
</tbody>
375
12/30/2018

<tbody>
</tbody>
1/5/2019

<tbody>
</tbody>
210-908-5231

<tbody>
</tbody>
Pear224
12/30/2018

<tbody>
</tbody>
1/5/2019

<tbody>
</tbody>
210-361-8442

<tbody>
</tbody>
Grape846
3/26/2019

<tbody>
</tbody>
4/1/2019

<tbody>
</tbody>
210-361-5592

<tbody>
</tbody>
Lemon552
5/26/2019

<tbody>
</tbody>
6/1/2019

<tbody>
</tbody>
210-361-5592

<tbody>
</tbody>

<tbody>
</tbody>

<tbody>
</tbody>



Table B

IDMaster DatePhone Number
2241/3/19
210-361-8442

<tbody>
</tbody>
8463/27/19210-361-5592
8464/22/19210-361-5592

<tbody>
</tbody>
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try this Array formula on sheet1

{=IFERROR(INDEX('Weekly Run Spots'!$E$2:$E$14,MAX(IF(('Weekly Run Spots'!$O$2:$O$14=E2)*('Weekly Run Spots'!$K$2:$K$14<=C2)*('Weekly Run Spots'!$L$2:$L$14>=C2),ROW('Weekly Run Spots'!$A$2:$A$14)))-1),IFERROR(INDEX('Weekly Run Spots'!$E$2:$E$14,MAX(IF(('Weekly Run Spots'!$O$2:$O$14=E2)*('Weekly Run Spots'!$L$2:$L$14=MAX(IF('Weekly Run Spots'!$L$2:$L$14<C2,'Weekly Run Spots'!$L$2:$L$14))),ROW('Weekly Run Spots'!$A$2:$A$14)))-1),"Number not exists"))}

Notes:
- The dates on sheet1 in column C must contain only the date, they currently have date and time.
- Change 14 in all ranges of the formula for the last row with data from the "Weekly Run Spots" sheet.


Attach the file with the test:

https://www.dropbox.com/s/2vbrgjftqdhu822/Sample Data.xlsx?dl=0
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,164
Members
448,870
Latest member
max_pedreira

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