[Formula Help] Find 'Name' within separate Range and pull the lowest of multiple 'Dates' and also the corresponding 'Contract Number' for that Date

NJ7

New Member
Joined
Jun 30, 2020
Messages
6
Office Version
  1. 365
Platform
  1. Windows
My goal is to fill the yellow-highlighted table in the 'Output Table' tab.

I want to find the Nearest Contract Expiration Date (to TODAY() if possible) based on the name in Column C.

My issue is there are multiple "Color" contracts, each having their own expiration date and possibly contract number.

So if possible, I went to find "John" in the "Data Table" tab, locate the nearest of the 4 "Color" dates, and then also grab the corresponding Contract Number to that date.

Is this possible? I have tried to simplify it the best I can, but unfortunately due to the nature of the data I am afraid this is as simple as it gets.

Thank you in advance!

Output Table:


Nearest Contract Expiration DateContract Number for Nearest Contract Expiration DateName
John
Luke
Bryan
Jake

Data Table:

BlueYellowGreenRed
NameContractExpirationContractExpirationContractExpirationContractExpiration
John
12345
1/1/2025
11234
1/1/2026
11123
1/1/2028
11112
1/1/2027
Luke
23456
2/2/2026
22345
2/2/2028
22234
2/2/2027
22223
2/2/2025
Bryan
34567
3/3/2027
33456
3/3/2026
33345
3/3/2025
33334
3/3/2028
Jake
45678
4/4/2028
44567
4/4/2027
44456
4/4/2026
44445
4/4/2025
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Wow - my apologies on the horrible formatting, I am unable to figure out how to post my workbook and it did not like how I copied my tables in - nor can I edit the post.

Igoring the colors at the top - Each bundle of "Contract & Expiration" equates to one of the colors. So column B and C = Blue, etc.
 
Upvote 0
Hi & welcome to MrExcel.
Do you have the dynamic array functions yet?
 
Upvote 0
Ok, that makes it more difficult, but need to check that is this what you want?

+Fluff New.xlsm
ABCDEFGHIJKLMNO
1Nearest Contract Expiration DateContract Number for Nearest Contract Expiration DateNameNameContractExpirationContractExpirationContractExpirationContractExpiration
201/01/202512345JohnBryan3456703/03/20273345603/03/20263334503/03/20253333403/03/2028
302/02/202522223LukeJake4567804/04/20284456704/04/20274445604/04/20264444504/04/2025
403/03/202533345BryanJohn1234501/01/20251123401/01/20261112301/01/20281111201/01/2027
504/04/202544445JakeLuke2345602/02/20262234502/02/20282223402/02/20272222302/02/2025
Main
Cell Formulas
RangeFormula
A2:A5A2=MIN(FILTER(FILTER($H$2:$O$5,$G$2:$G$5=C2),$H$1:$O$1="Expiration"))
B2:B5B2=INDEX(FILTER($H$2:$O$5,$G$2:$G$5=C2),MATCH(A2,FILTER($H$2:$O$5,$G$2:$G$5=C2),0)-1)
 
  • Like
Reactions: NJ7
Upvote 0
That is exactly what I am looking for - but the FILTER function does not appear to be available to me.
 
Upvote 0
Filter is one of the dynamic array functions, which you should get shortly.
In the mean time, how about
+Fluff New.xlsm
ABCDEFGHIJKLMNO
1Nearest Contract Expiration DateContract Number for Nearest Contract Expiration DateNameNameContractExpirationContractExpirationContractExpirationContractExpiration
201/01/202512345JohnBryan3456703/03/20273345603/03/20263334503/03/20253333403/03/2028
302/02/202522223LukeJake4567804/04/20284456704/04/20274445604/04/20264444504/04/2025
403/03/202533345BryanJohn1234501/01/20251123401/01/20261112301/01/20281111201/01/2027
504/04/202544445JakeLuke2345602/02/20262234502/02/20282223402/02/20272222302/02/2025
Main
Cell Formulas
RangeFormula
A2:A5A2=MINIFS(INDEX($H$2:$O$5,MATCH(C2,$G$2:$G$5,0),0),$H$1:$O$1,"Expiration")
B2:B5B2=INDEX($H$2:$O$5,MATCH(C2,$G$2:$G$5,0),MATCH(A2,INDEX($H$2:$O$5,MATCH(C2,$G$2:$G$5,0),),0)-1)
 
  • Like
Reactions: NJ7
Upvote 0
Filter is one of the dynamic array functions, which you should get shortly.
In the mean time, how about
+Fluff New.xlsm
ABCDEFGHIJKLMNO
1Nearest Contract Expiration DateContract Number for Nearest Contract Expiration DateNameNameContractExpirationContractExpirationContractExpirationContractExpiration
201/01/202512345JohnBryan3456703/03/20273345603/03/20263334503/03/20253333403/03/2028
302/02/202522223LukeJake4567804/04/20284456704/04/20274445604/04/20264444504/04/2025
403/03/202533345BryanJohn1234501/01/20251123401/01/20261112301/01/20281111201/01/2027
504/04/202544445JakeLuke2345602/02/20262234502/02/20282223402/02/20272222302/02/2025
Main
Cell Formulas
RangeFormula
A2:A5A2=MINIFS(INDEX($H$2:$O$5,MATCH(C2,$G$2:$G$5,0),0),$H$1:$O$1,"Expiration")
B2:B5B2=INDEX($H$2:$O$5,MATCH(C2,$G$2:$G$5,0),MATCH(A2,INDEX($H$2:$O$5,MATCH(C2,$G$2:$G$5,0),),0)-1)

First - thank you so much. These do infact work and I am able to get the information as required.

Second - I have been running into issues when sorting other columns. These formula don't 'stay' with the cells. For example, in the above table, if I sort column "D" smallest to largest, the formula in cell A2 would still be linking to cells in line 4 - does that make sense?

I have tried a few different ways to amend this, but the whole idea of using these formulas is to get a "days to expiration" using the date it is pulling, so the table will constantly be sorting "Days to expiration" from smallest to largest when new data is pasted in.
 
Upvote 0
The formulae are tied to the name in col C, if you sort col C the formulae will continue to pull information for that person.
 
Upvote 0
So I actually doubled the formula in Column B, so I have these formulas in Columns A, B, and C.

What you are saying is I can't sort by any other column other than the columns these formulas pull from?
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

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