Lookup return multiple results

EssKayKay

Board Regular
Joined
Jan 5, 2003
Messages
233
Office Version
  1. 2007
Platform
  1. Windows
Is it possible to have a lookup table return numerous answers?

Example:

Lookup Table
5/4/2005 Dog
5/5/2005 Cat
5/5/2005 Mouse
5/6/2005 Pig

Keyin Lookup = 5/5/2005

Returns:
Cat, Mouse

Thanks,
SKK
 
OK. Try in D1 and copy down,

=IF(ROWS($1:1)+1-MATCH(9.9E+307,$C$1:C1)<=COUNTIF($A$1:$A$5,LOOKUP(9.9E+307,$C$1:C1)),INDEX($B$1:$B$5,SMALL(IF($A$1:$A$5=LOOKUP(9.9E+307,$C$1:C1),ROW($B$1:$B$5)),ROWS($1:1)+1-MATCH(9.9E+307,$C$1:C1))),"")

Note: This is a pretty expensive formula and if you apply this for 300 dates, it would definitely affect the performace of the file.

You could also consider Advanced Filter for this.

HTH
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Thanks Krishnakumar your formula works.

Code:
=IF(ROWS($1:2)+1-MATCH(9.9E+307,$C$1:C2)<=COUNTIF($A$1:$A$7000,LOOKUP(9.9E+307,$C$1:C2)),INDEX($B$1:$B$7000,SMALL(IF($A$1:$A$7000=LOOKUP(9.9E+307,$C$1:C2),ROW($B$1:$B$7000)),ROWS($1:2)+1-MATCH(9.9E+307,$C$1:C2))),"")
Sample1.xls
ABCDE
1
25/4/2005Dog5/5/2005cat
35/5/2005catMoues
45/5/2005MouesCow
55/4/2005Pig 
65/5/2005Cow 
75/4/2005Dog
8Pig
9 
10
11
12
Sheet1




But when I tried to apply your formula to another sheet it gives me a N/A


I notice it does not work if there are dashes ( - ) in the part#.

Why is that?
Sample1.xls
ABCD
1
202-01349Dog02-01-349#N/A
3407657-0004Cat#N/A
402-01350Mouse#N/A
5407657-0005Pig#N/A
602-01351Cow#N/A
7407657-0005#N/A
8#N/A
9#N/A
10
11
Sheet3



Anyone has any ideas?
 
Upvote 0
When you applied to another sheet, did you copy the CELL or did you use F2 edit mode and copy just the formula...

Did you confirm with CTRL SHIFT ENTER?
 
Upvote 0
I select the cell then I went to the formula bar and I copy the formula then I hit esc then I paste the formula into the other worksheet and yes I did confirm CTRL+SHIFT+ENTER. This is very weird. What do you think?
 
Upvote 0
Hi,

Try,

=IF(ROWS($1:1)+1-MATCH("zzzzzzz",$C$2:C2)<=COUNTIF($A$2:$A$6,LOOKUP("zzzzzzz",$C$2:C2)),INDEX($B$1:$B$6,SMALL(IF($A$2:$A$6=LOOKUP("zzzzzzzz",$C$2:C2),ROW($B$2:$B$6)),ROWS($1:1)+1-MATCH("zzzzzzzzzz",$C$2:C2))),"")

I notice it does not work if there are dashes ( - ) in the part#.

9.9E+307 won't work with text values as your part# are text values.

HTH
 
Upvote 0
Your formula works but when I tried to add this into the formula it gives me a error. IF(A2="","",

=IF(A2="","",IF(ROWS(1:2)+1-MATCH(BigStr,$A$1:$A2)<=COUNTIF(Data!$C$1:$C$7000,LOOKUP(BigStr,$A$1:$A2)),INDEX(Data!E$1:E$7000,SMALL(IF(Data!$C$1:$C$7000=LOOKUP(BigStr,$A$1:$A2),ROW(Data!E$1:E$7000)),ROWS(1:2)+1-MATCH(BigStr,$A$1:$A2))),0))

This is the error its giving me #NUM!

Is there a way it could be fixed?
 
Upvote 0
Hi,

Why do you want to add this? In my formula if there are no values to return then the cell remains empty. See the bolded part.

=IF(ROWS($A$1:A1)+1-MATCH("zzzzzzz",$C$2:C2)<=COUNTIF($A$2:$A$6,LOOKUP("zzzzzzz",$C$2:C2)),INDEX($B$1:$B$6,SMALL(IF($A$2:$A$6=LOOKUP("zzzzzzzz",$C$2:C2),ROW($B$2:$B$6)),ROWS($A$1:A1)+1-MATCH("zzzzzzzzzz",$C$2:C2))),"")

HTH
 
Upvote 0
I'm sorry I meant "YES"



=IF(A2="","YES",IF(ROWS(1:2)+1-MATCH(BigStr,$A$1:$A2)<=COUNTIF(Data!$C$1:$C$7000,LOOKUP(BigStr,$A$1:$A2)),INDEX(Data!E$1:E$7000,SMALL(IF(Data!$C$1:$C$7000=LOOKUP(BigStr,$A$1:$A2),ROW(Data!E$1:E$7000)),ROWS(1:2)+1-MATCH(BigStr,$A$1:$A2))),0))

How to implement that in the formula?
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,922
Members
449,094
Latest member
teemeren

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