Formula to match a value and return multiple results?

haste

New Member
Joined
Sep 27, 2011
Messages
5
Hi there,

I'm looking for a formula to match a value within an array and return the results found.

I know how to you use vlookup/match/index formula's, but I can only return the first match found. I would like to return the first match in cell A1 and the second match inside A2, third inside A3, etc.

So when the first match is found and placed inside A1 then the formula inside A2 should ignore the first match that is already found and show the next match value.

I would like to get this done with a formula and not with the autofilter option inside Excel.

I created an example: http://www.haste.nl/formula-filter.zip

Thanks for helping out!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi and welcome,

Try this Array-formula in B4

=IF(COUNTIF($E$2:$E$17,$B$2)>=ROWS($B$4:B4),INDEX($D$2:$D$17,SMALL(IF($E$2:$E$17=$B$2,ROW($E$2:$E$17)-ROW($E$2)+1),ROWS($B$4:B4))),"")

confirmed with Ctrl+Shift+Enter

copy down

M.
 
Upvote 0
Hi Marcelo,

This is the formula I was looking for. Your quick reply is really amazing! :)

Thanks a lot for your help!

Regards
Haste
 
Upvote 0
Hi there,

I'm looking for a formula to match a value within an array and return the results found.

I know how to you use vlookup/match/index formula's, but I can only return the first match found. I would like to return the first match in cell A1 and the second match inside A2, third inside A3, etc.

So when the first match is found and placed inside A1 then the formula inside A2 should ignore the first match that is already found and show the next match value.

I would like to get this done with a formula and not with the autofilter option inside Excel.

I created an example: http://www.haste.nl/formula-filter.zip

Thanks for helping out!
See this...

Lookup when there are multiple instances of the lookup value

http://www.mrexcel.com/forum/showpost.php?p=2696961&postcount=3
 
Upvote 0
Thanks T. Valko

I've searched for something like this, but it's hard to find when English is not your main language. So I was only running into the standard formulas.

Great that this forum gives so much support for Excel! :)
You're welcome. Thanks for the feedback! :cool:
 
Upvote 0
Curious if you can help me out with my next question.

What if I also want to perform a check on the result and make sure that the result returned (ID) is unique?

Let's say I'm looking for ID's that match status A and it returns:
1000
1001
1003
1000
1004

Now it's showing ID 1000 twice, but I only want it once. Is this possible? :)
 
Upvote 0
Maybe this Array-formula in B4 (Excel 2007 or higher)

=IFERROR(INDEX($D$2:$D$17,SMALL(IF($E$2:$E$17=$B$2,IF(COUNTIF(OFFSET($D$2,0,0,ROW($D$2:$D$17)-ROW($D$2)+1,1),$D$2:$D$17)=1,ROW($E$2:$E$17)-ROW($E$2)+1)),ROWS($B$4:B4))),"")

Ctrl+Shift+Enter

copy down

M.
 
Upvote 0
Curious if you can help me out with my next question.

What if I also want to perform a check on the result and make sure that the result returned (ID) is unique?

Let's say I'm looking for ID's that match status A and it returns:
1000
1001
1003
1000
1004

Now it's showing ID 1000 twice, but I only want it once. Is this possible? :)
Try this...

Book1
ABCDE
1StatusID_StatusID
2A1001_A1001
3A1005__1005
4A1005___
5A1005___
6B1000___
7B1002___
8B1003___
9B1004___
10C1002___
11C1002___
12C1005___
13D1002___
14D1005___
15D1005___
Sheet1

Enter this formula in E2:

=IFERROR(INDEX(B2:B15,MATCH("A",A2:A15,0)),"")

Enter this array formula** in E3:

=IFERROR(INDEX(B$2:B$15,MATCH(1,(A$2:A$15="A")*(COUNTIF(E$2:E2,B$2:B$15)=0),0)),"")

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.

Copy down until you get blanks.
 
Upvote 0

Forum statistics

Threads
1,215,347
Messages
6,124,421
Members
449,157
Latest member
mytux

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