Vlookup or Index for multiple results two different sheets

kac1125

Board Regular
Joined
Jul 31, 2014
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hello,

Looking do do a vlookup to pull back multiple records for the same lookup value. for example in sheet1 starting A1[TABLE="width: 500"]
<tbody>[TR]
[TD]Item[/TD]
[TD]Vendor[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]11237[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I want to lookup all values that start with 11237 in sheet2 starting A1
[TABLE="width: 500"]
<tbody>[TR]
[TD]Vendor ship[/TD]
[/TR]
[TR]
[TD]11237-00001
[/TD]
[/TR]
[TR]
[TD]11237-00003
[/TD]
[/TR]
[TR]
[TD]11237-00002[/TD]
[/TR]
[TR]
[TD]18716-00001
[/TD]
[/TR]
[TR]
[TD]18213-00004[/TD]
[/TR]
[TR]
[TD]19173-00001[/TD]
[/TR]
</tbody>[/TABLE]

So I want it to pull back
[TABLE="width: 500"]
<tbody>[TR]
[TD]Item[/TD]
[TD]Vendor[/TD]
[TD]Vendor ship[/TD]
[/TR]
[TR]
[TD]1234[/TD]
[TD]11237[/TD]
[TD]11237-00001[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]11237-00003[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]11237-00002[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Any help would be much appreciated.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try (untested)

=IFERROR(INDEX(Sheet2!A$1:A$1000,AGGREGATE(15,6,ROW(A$1:A$1000)/(VLOOKUP(1234,Sheet1!A$1:B$1000,2,0)=(LEFT(Sheet2!A$1:A$1000,5)+0)),ROWS(A$1:A1))-(1-1),COLUMN()-(COLUMN()-1),1),"")

or this (array formula)
=IFERROR(INDEX(Sheet1!$A$1:$A$1000,SMALL(IF((VLOOKUP(1234,Sheet1!A$1:B$1000,2,0)=(LEFT(Sheet2!A$1:A$1000,5)+0)),ROW($A$1:$A$1000)),ROW(A1))-(ROW(A$1)-1),COLUMN()-(COLUMN()-1),1,"")

Not sure if the LEFT() will work on a range though
 
Upvote 0
Same idea as post by Special-K99, but a little shorter.
Formula in C2 is an array formula that must be entered with CTRL-SHIFT-ENTER.
If you have Excel ver. 2010 or later you could the formula in D2.

Both of these formulas assume the Vender Number in cell B1 is numeric and not text.
If it's text change the formulas to:

[TABLE="width: 1285"]
<colgroup><col></colgroup>[TR]
[TD]=IFERROR(INDEX(Sheet2!$A$2:$A$7,SMALL(IF(LEFT(Sheet2!$A$2:$A$7,LEN($B$2))=Sheet1!$B$2,ROW(Sheet2!$A$2:$A$7)-ROW(Sheet2!$A$2)+1),ROWS($C$2:C2))),"")[/TD]
[/TR]
[/TABLE]
or
[TABLE="width: 1285"]
<colgroup><col></colgroup>[TR]
[TD]=IFERROR(INDEX(Sheet2!$A$2:$A$7,AGGREGATE(15,6,(ROW(Sheet2!$A$2:$A$7)-ROW(Sheet2!$A$2)+1)/(LEFT(Sheet2!$A$2:$A$7,LEN($B$2))=$B$2),ROWS($D$2:D2))),"")

Excel Workbook
ABCD
1ItemVendorVendor shipVendor ship
212341123711237-0000111237-00001
311237-0000311237-00003
411237-0000211237-00002
Sheet1
Excel Workbook
A
1Vendor ship
211237-00001
311237-00003
411237-00002
518716-00001
618213-00004
719173-00001
Sheet2



<strike></strike>
[/TD]
[/TR]
[/TABLE]
<strike></strike>
 
Upvote 0
Thank you very much! I really appreciate your help on this!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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