Lookup return multiple results

EssKayKay

Board Regular
Joined
Jan 5, 2003
Messages
221
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
 
You can also use filters.
Partslookup.xls
ABCDEF
1MakeyearModelPart 1Part2notes
2toyota2005camary190930034cly
3toyota2005camary121632161.3
4honda2004accord131845444cly
5toyota2004camary149448991.6
6lexus2003ex300230345576cly
7cheverolet2001ck series16934553v8
8honda2001civic141946891.4
Data


The above [old] sample, with this code<font face=Courier New><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> Worksheet_BeforeDoubleClick(<SPAN style="color:#00007F">ByVal</SPAN> Target<SPAN style="color:#00007F">As</SPAN> Range, Cancel<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Boolean</SPAN>)
    <SPAN style="color:#00007F">If</SPAN> Intersect(Target, [A1:F1])<SPAN style="color:#00007F">Is</SPAN><SPAN style="color:#00007F">Nothing</SPAN><SPAN style="color:#00007F">Then</SPAN><SPAN style="color:#00007F">Exit</SPAN><SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#00007F">If</SPAN> [A:F].AutoFilter =<SPAN style="color:#00007F">False</SPAN><SPAN style="color:#00007F">Then</SPAN>
        [A:F].AutoFilter
    <SPAN style="color:#00007F">Else</SPAN>
        [A:F].AutoFilter Field:=1
        [A:F].AutoFilter Field:=2
        [A:F].AutoFilter Field:=3
        [A:F].AutoFilter Field:=4
        [A:F].AutoFilter Field:=5
    <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">If</SPAN>
    Cancel =<SPAN style="color:#00007F">True</SPAN><SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>

A double click in any cell in A1:F1 toggles filters on/off, then use the filters to select your criteria.

The results can of course be copied to other sheets.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Thanks Kris (et al), I think I got it. I'm off till tomorrow but will try in AM.

Thanks again,
sKK
 
Upvote 0
Kris,

Is it possible to move all data down one row(i.e., start on row 2 vs. 1)? I'd like column headings in row 1. I've been playing with it but continue to receive errors. This info is actually coming from an Access table. The spreadsheet will be linked to the DB.

Not being much of a programmer leaves me helpless.
Thanks,
SKK
 
Upvote 0
SKK

You say this data is coming from Access?

So why not just use a query in Access to return the required results?:)

If you need to pass some sort of parameter, from say a range, then Excel help details how to do it.
 
Upvote 0
EssKayKay said:
Kris,

Is it possible to move all data down one row(i.e., start on row 2 vs. 1)? I'd like column headings in row 1. I've been playing with it but continue to receive errors. This info is actually coming from an Access table. The spreadsheet will be linked to the DB.

Not being much of a programmer leaves me helpless.
Thanks,
SKK

Try,

IF(ROWS($1:1)<=COUNTIF($A$2:$A$100,$C$2),INDEX($B$1:$B$100,SMALL(IF($A$2:$A$100=$C$2,ROW($B$2:$B$100)),ROWS($1:1))),"")

You could also consider Pivot Table as an alternative.

HTH
 
Upvote 0
Krishnakumar said:
Try,
Book1
ABCD
15/4/2005Dog5/5/2005cat
25/5/2005catMoues
35/5/2005MouesCow
45/6/2005Pig 
55/5/2005Cow
Sheet4


Formula in D1 and copy down,

=IF(ROWS($1:1)<=COUNTIF($A$1:$A$5,$C$1),INDEX($B$1:$B$5,SMALL(IF($A$1:$A$5=$C$1,ROW($B$1:$B$5)),ROWS($1:1))),"")

Is there way if 2 words do match then just grab the first text.

either VLOOKUP or INDEX/MATCH

HTH



Hi Krishnakumar


I have a similar problem and I used your solution and it works. But if you can, could you break it down piece by piece that how the formula works?
 
Upvote 0
Krishnakumar,

I copy your formula down in column D but it did not get me the correct result in cell D6 and D7. It should give me Dog & pig
Sample1.xls
ABCDE
15/4/2005Dog5/5/2005cat
25/5/2005catMoues
35/5/2005MouesCow
45/4/2005Pig 
55/5/2005Cow 
65/4/2005 
7 
8 
Sheet1





Now in this example I had to manually adjust the ranges in the formula to get the correct result. Can the formula be modified so all I have to do is copy the formula down from D1?
Sample1.xls
ABCDE
15/4/2005Dog5/5/2005cat
25/5/2005catMoues
35/5/2005MouesCow
45/4/2005Pig 
55/5/2005Cow 
65/4/2005Dog
7Pig
8 
9
10
Sheet2
 
Upvote 0
Hi,
Book5
ABCDE
15/4/2005Dog5/5/20055/4/2005
25/5/2005catcatDog
35/5/2005MouesMouesPig
45/4/2005PigCow 
55/5/2005Cow  
Sheet1


Does it help you? if you want down the column then a pivot table is the better option.

Formula in D2 and copy across & down,

=IF(ROWS($1:1)<=COUNTIF($A$1:$A$5,D$1),INDEX($B$1:$B$5,SMALL(IF($A$1:$A$5=D$1,ROW($B$1:$B$5)),ROWS($1:1))),"")

HTH
 
Upvote 0
I was going to do that but there are 3000 dates and going across only goes up to 256 columns but the sample I posted is just example. I will look into the pivot table. But if it possible to copy down the formula that will be great.

Is it possible?
 
Upvote 0

Forum statistics

Threads
1,214,594
Messages
6,120,436
Members
448,964
Latest member
Danni317

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