Return Date from Matched Adjacent Cell which is Closest to Current Adjacent Cell

Tguillaume

New Member
Joined
Aug 2, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I currently have two tables. Table 1 includes a patient's Unique ID and when they visited the hospital (Hospital Visit). In Table 2, there is also the Unique ID, but instead of Hospital Visit I have the date that the patient's primary doctor called to follow up with the patient after their hospital visit. I have made the data simpler below, but it shows how it is organized.

1632864692432.png


I need to create a third table which pulls the Doctor's Call date which is closest to the Hospital Visit date, but not before the Hospital Visit date. For example, Table 3 should look like this:

1632865135663.png

I need help with a formula that I would use in column J (Doctor's Call).

I've tried using combinations of IF(), COUNTIF(), AND(), and other formulas to achieve this goal but I am stuck. I would appreciate any help in learning how to match on the Unique IDs and then pull in the date I desire from a range of dates in the adjacent cell. I know I can use INDEX MATCH to pull in the most recent Doctor's Call, but this may not be the one I need (the Doctor's Call that is soonest after the Hospital Visit).

Thanks for any help!
 

Attachments

  • 1632864849791.png
    1632864849791.png
    7.2 KB · Views: 14

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:
Book1
ABCDEFGHIJ
1
2IDHosp. VisitIDDoctor callIDHosp. VisitCall
3John Smith1/1/2021John Smith12/31/2020John Smith1/1/20211/4/2021
4Jane Smith2/12/2021John Smith1/4/2021Jane Smith2/12/20212/15/2021
5Robert Brown3/4/2021John Smith1/7/2021Robert Brown3/4/20213/5/2021
6Saah Jane4/15/2021Jane Smith2/10/2021Saah Jane4/15/20214/17/2021
7Jane Smith2/15/2021
8Robert Brown3/5/2021
9Saah Jane4/12/2021
10Saah Jane4/14/2021
11Saah Jane4/17/2021
Sheet1
Cell Formulas
RangeFormula
J3:J6J3=MIN(FILTER($F$3:$F$11,(H3=$E$3:$E$11)*($F$3:$F$11>=I3)))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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