Index and Match using Small on condition

rex759

Well-known Member
Joined
Nov 8, 2004
Messages
608
Office Version
  1. 365
Platform
  1. Windows
Hello,

My goal is to pull the first and second appropriate date in column E if the ID number occurs a second time in column D.
The formula I am using is always pulling the second date if it exists. I thought I could use IFERROR or ISERROR on SMALL so if not found, it would use the traditional INDEX and MATCH. That didn’t work for me either.

Any ideas?

Thanks in advance

Book1
ABCDEF
1Individual WkbkMASTER
2Product IDDateProduct IDDate
31452/5/20191452/7/20192/7/2019
469422/6/201969422/6/2019
51452/7/20191452/7/2019
66622/8/20196622/11/2019
719572/9/201919572/9/2019
88182/10/20198182/10/2019
96622/11/20196622/11/2019
1063492/12/201963492/12/2019
1161692/13/201961692/13/2019
Sheet1
Cell Formulas
RangeFormula
F3F3{=IFERROR(INDEX($B$3:$B$11,SMALL(IF($A$3:$A$11=D3,ROW($B$3:$B$11)-ROW($B$3)+1,ROW($E$11)+1),2),1),INDEX($B$3:$B$11,MATCH(D3,$A$3:$A$11,0),0))}
B4:B11B4=B3+1
E3:E11E3{=IF(COUNTIF($D$3:$D$11,D3)>1,INDEX($B$3:$B$11,SMALL(IF($A$3:$A$11=D3,ROW($B$3:$B$11)-ROW($B$3)+1,ROW($E$11)+1),2),1),INDEX($B$3:$B$11,MATCH(D3,$A$3:$A$11,0),0))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Is this what you are trying to do?

Book1
ABCDE
1Individual WkbkMASTER
2Product IDDateProduct IDDate
31452/5/20191452/5/2019
469422/6/201969422/6/2019
51452/7/20191452/7/2019
66622/8/20196622/8/2019
719572/9/201919572/9/2019
88182/10/20198182/10/2019
96622/11/20196622/11/2019
1063492/12/201963492/12/2019
1161692/13/201961692/13/2019
Sheet1
Cell Formulas
RangeFormula
B4:B11B4=B3+1
E3:E11E3{=INDEX($B$3:$B$11,SMALL(IF($A$3:$A$11=$D3,ROW($A$3:$A$11)-ROW($A$3)+1),COUNTIF($A$3:A3,$D3)))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Yes! I wasnt even close!! Thank you very much.
 
Upvote 0
You're welcome. Actual you were pretty close.
If you have Excel 2016 or later you could use the following formula that doesn't require CTRL-SHIFT-ENTER. Just enter.

Book1
ABCDE
1Individual WkbkMASTER
2Product IDDateProduct IDDate
31452/5/20191452/5/2019
469422/6/201969422/6/2019
51452/7/20191452/7/2019
66622/8/20196622/8/2019
719572/9/201919572/9/2019
88182/10/20198182/10/2019
96622/11/20196622/11/2019
1063492/12/201963492/12/2019
1161692/13/201961692/13/2019
Sheet1
Cell Formulas
RangeFormula
B4:B11B4=B3+1
E3:E11E3=INDEX($B$3:$B$11,AGGREGATE(15,6,(ROW($A$3:$A$11)-ROW($A$3)+1)/($A$3:$A$11=$D3),COUNTIF($A$3:A3,$D3)))
 
Upvote 0
Hmmm, when I applied a sort to column D I get #num errors. do not line up, I get a #num error. Do the ID# have to be in the same row to work?
 
Upvote 0
My mistake. Change the COUNTIF in both formulas from:
COUNTIF($A$3:A3,$D3) to:
COUNTIF($D$3:D3,$D3)

Book1
ABCDE
1Individual WkbkMASTER
2Product IDDateProduct IDDate
31452/5/20191452/5/2019
469422/6/20191452/7/2019
51452/7/20196622/8/2019
66622/8/20196622/11/2019
719572/9/20198182/10/2019
88182/10/201919572/9/2019
96622/11/201961692/13/2019
1063492/12/201963492/12/2019
1161692/13/201969422/6/2019
Sheet3
Cell Formulas
RangeFormula
E3:E11E3=INDEX($B$3:$B$11,AGGREGATE(15,6,(ROW($A$3:$A$11)-ROW($A$3)+1)/($A$3:$A$11=$D3),COUNTIF($D$3:D3,$D3)))


Book1
ABCDE
1Individual WkbkMASTER
2Product IDDateProduct IDDate
31452/5/20191452/5/2019
469422/6/20191452/7/2019
51452/7/20196622/8/2019
66622/8/20196622/11/2019
719572/9/20198182/10/2019
88182/10/201919572/9/2019
96622/11/201961692/13/2019
1063492/12/201963492/12/2019
1161692/13/201969422/6/2019
Sheet4
Cell Formulas
RangeFormula
E3:E11E3{=INDEX($B$3:$B$11,SMALL(IF($A$3:$A$11=$D3,ROW($A$3:$A$11)-ROW($A$3)+1),COUNTIF($D$3:D3,$D3)))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0

Forum statistics

Threads
1,215,632
Messages
6,125,909
Members
449,274
Latest member
mrcsbenson

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