VLOOKUP on one set of criteria and return multiple matches in a row?

Kelvinator1

New Member
Joined
May 18, 2022
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I have two reports, one that has aged inventory data and the other that has sales data with inventory items on it. What I am trying to do is look up the item number from the aged inventory report and then go to the sales report, find that same item number and return all the customer names that have purchased that item and put the results in a row (across a bunch of columns). The aged inventory report is small (59 rows) compared to the sales report (2229 rows). I tried using index, small, row, column based on an example I found online, but it didn't work because my data are in two different files and are two different sizes. Any ideas?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
At the moment we have to guess just how your data is laid out and what it is actually like. We also have to manually type any thing to test with. You will generally get much faster/better responses if you provide some sample data and expected results in a form that helpers can easily copy from.

For the future, MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

Assuming below is doing the sort of thing you are after, see if you can adapt it to your own circumstances.

24 08 28.xlsm
ABCDEFGHIJK
1SalesAged
2ItemResultItem
3Item 1VItem 1VIG
4Item 7DItem 2 
5Item 3BItem 3BDWZK
6Item 1IItem 4B
7Item 7OItem 5DJP
8Item 3DItem 6NV
9Item 3WItem 7DOA
10Item 3ZItem 8 
11Item 4BItem 9J
12Item 7A
13Item 1G
14Item 9J
15Item 5D
16Item 5J
17Item 6N
18Item 5P
19Item 6V
20Item 3K
Kelvinator1
Cell Formulas
RangeFormula
F3:H3,F9:H9,F8:G8,F7:H7,F5:J5,F4,F6,F10:F11F3=TRANSPOSE(FILTER(B$3:B$20,A$3:A$20=E3,""))
Dynamic array formulas.
 
Upvote 0
This may help.
1724821145750.png

In E3
Excel Formula:
=LET(a,A3:A9,au,UNIQUE(a),b,B3:B9,c,BYROW(au,LAMBDA(ro,TEXTJOIN("_",TRUE,FILTER(b,a=ro)))),d,TEXTSPLIT(TEXTJOIN(",",FALSE,c),"_",",",FALSE,0,""),HSTACK(au,IFERROR(VALUE(d),"")))
 
Upvote 0
At the moment we have to guess just how your data is laid out and what it is actually like. We also have to manually type any thing to test with. You will generally get much faster/better responses if you provide some sample data and expected results in a form that helpers can easily copy from.

For the future, MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

Assuming below is doing the sort of thing you are after, see if you can adapt it to your own circumstances.

24 08 28.xlsm
ABCDEFGHIJK
1SalesAged
2ItemResultItem
3Item 1VItem 1VIG
4Item 7DItem 2 
5Item 3BItem 3BDWZK
6Item 1IItem 4B
7Item 7OItem 5DJP
8Item 3DItem 6NV
9Item 3WItem 7DOA
10Item 3ZItem 8 
11Item 4BItem 9J
12Item 7A
13Item 1G
14Item 9J
15Item 5D
16Item 5J
17Item 6N
18Item 5P
19Item 6V
20Item 3K
Kelvinator1
Cell Formulas
RangeFormula
F3:H3,F9:H9,F8:G8,F7:H7,F5:J5,F4,F6,F10:F11F3=TRANSPOSE(FILTER(B$3:B$20,A$3:A$20=E3,""))
Dynamic array formulas.

Hi Peter:

Sorry for not including examples of the data, I now have downloaded Xl2bb and am attaching the mini sheets. I think I forgot to mention that the Aged Inventory sheet is a table that is pulling data out of SAP. For this purpose I have copied and pasted the data, but it still acts like a table. So, the first mini sheet is the Aged Inventory Report with all the extra columns hidden except for the item number, name, and then the columns for the customers that I want to fill automatically. I have also hidden everything after row 9 to make the data smaller. The second mini sheet is the Sales Report that has the sales data by customer and item number. The third mini sheet is where I manually found the customers for each of the items and copied them into columns, which is what the expected result would be when I put in a formula to do this automatically. The fourth mini sheet is the result when I used your formula. As you can see, I get #SPILL! errors for any items that have more than one customer, and then it pulls in the customer name if the item has only been sold to one customer. So how can we get the result in Mini Sheet #3 automatically? Thank you for your reply and any future help you could give me.

CFarms Aged Inventory 8-21-24 for testing with customers.xlsx
CDVWXYZ
1Mini Sheet #1
2Item CodeItem NameCustomersCustomers2Customers3Customers4Customers5
3FG-PPAJ-040-000-C44Aji Amarillo, Ground , Untreated, 44.09 lb Carton
4FG-PPAJ-040-000-C44Aji Amarillo, Ground , Untreated, 44.09 lb Carton
5FG-PPAN-014-002-C25Chile, Ancho, Flake, Irradiated, 25 lb Carton
6FG-PPAN-014-002-C30Chile, Ancho, Flake, Irradiated, 30 lb Carton
7FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb Carton
8FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb Carton
9FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb Carton
10FG-PPAN-052-002-P40Chile, Ancho Chile, Frozen Puree, Irradiated, 40 lb Pail
61
Data with blank customers


The Sales Report that shows the customers and item numbers they purchased:

CFarms Aged Inventory 8-21-24 for testing with customers.xlsx
ABCDE
1Mini Sheet #2
2DocNumberCustomerNameWarehouseItemCodeItemName
357429JUAN JOSÉ ALBARRACÍN, S.A.DIRECT WAREHOUSEFG-PPJR-016-000-C36Chile, Red Jalapeno, Rough Cut, Untreated, 35.273 lb Carton
457319HURON PRODUCE LIMITEDVALLEY COLD STORAGEFG-PPCP-017-000-G30Chile, Chipotle Morita, Pods with Stems, Untreated, 30 lb Bag
557439HURON PRODUCE LIMITEDVALLEY COLD STORAGEFG-PPCP-017-000-G30Chile, Chipotle Morita, Pods with Stems, Untreated, 30 lb Bag
657377HURON PRODUCE LIMITEDVALLEY COLD STORAGEFG-PPCP-017-000-G30Chile, Chipotle Morita, Pods with Stems, Untreated, 30 lb Bag
757489HURON PRODUCE LIMITEDVALLEY COLD STORAGEFG-PPCP-017-000-G30Chile, Chipotle Morita, Pods with Stems, Untreated, 30 lb Bag
856915HURON PRODUCE LIMITEDDIRECT WAREHOUSEFG-PPCP-017-000-G30Chile, Chipotle Morita, Pods with Stems, Untreated, 30 lb Bag
955954MANIKER F AND G CO., LTDCFARMS MAIN WAREHOUSEFG-BLHM-040-000-C44Blend, Habanero Blend, Ground, Untreated, 44.09 lb Carton
1056216MANIKER F AND G CO., LTDCFARMS MAIN WAREHOUSEFG-BLHM-040-000-C44Blend, Habanero Blend, Ground, Untreated, 44.09 lb Carton
1157290G.L. MEZZETTA, INC.CFARMS MAIN WAREHOUSEFG-TMC7-003-000-T40Tomato, California/Mexican Blend, Halves, 400 lb Tote
1256364JUAN JOSÉ ALBARRACÍN, S.A.DIRECT WAREHOUSEFG-PPJR-016-000-C36Chile, Red Jalapeno, Rough Cut, Untreated, 35.273 lb Carton
1357320G.L. MEZZETTA, INC.CFARMS MAIN WAREHOUSEFG-TMC7-003-000-T40Tomato, California/Mexican Blend, Halves, 400 lb Tote
1456865G.L. MEZZETTA, INC.CFARMS MAIN WAREHOUSEFG-TMC7-003-000-T40Tomato, California/Mexican Blend, Halves, 400 lb Tote
1557348MCCORMICK & COMP-MOJAVEVALLEY COLD STORAGEFG-PPPO-017-100-C25Chile, Pasilla Ancho, Pods with Stems, Untreated, 25 lb Carton
1656596G.L. MEZZETTA, INC.CFARMS MAIN WAREHOUSEFG-TMC7-003-000-T40Tomato, California/Mexican Blend, Halves, 400 lb Tote
1757321MANIKER F AND G CO., LTDCFARMS MAIN WAREHOUSEFG-BLHM-040-000-C56Blend, Habanero Blend, Ground, Untreated, 55.1 lb Carton
1855627MANIKER F AND G CO., LTDCFARMS MAIN WAREHOUSEFG-BLHM-040-000-C44Blend, Habanero Blend, Ground, Untreated, 44.09 lb Carton
1957205JUAN JOSÉ ALBARRACÍN, S.A.DIRECT WAREHOUSEFG-PPJR-016-000-C36Chile, Red Jalapeno, Rough Cut, Untreated, 35.273 lb Carton
2023-24 Sales thru August


The results when I manually looked up the item numbers in the Sales Report and copied and pasted them into the Aged Inventory Report:

CFarms Aged Inventory 8-21-24 for testing with customers.xlsx
CDVWXYZAA
1Mini Sheet #3
2Item CodeItem NameCustomersCustomers2Customers3Customers4Customers5Customers6
3FG-PPAJ-040-000-C44Aji Amarillo, Ground , Untreated, 44.09 lb CartonDEHYDRATES, INC.SKIDMORE SALES & DIST. CO. INC
4FG-PPAJ-040-000-C44Aji Amarillo, Ground , Untreated, 44.09 lb CartonDEHYDRATES, INC.SKIDMORE SALES & DIST. CO. INC
5FG-PPAN-014-002-C25Chile, Ancho, Flake, Irradiated, 25 lb CartonSAFEWAY, INC./SUPPLYGREEK ISLAND SPICEGOURMET FOODS INTERNATIONALEARTH & VINE PROVISIONS
6FG-PPAN-014-002-C30Chile, Ancho, Flake, Irradiated, 30 lb CartonSAFEWAY, INC./SUPPLYEARTH & VINE PROVISIONS
7FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb CartonBCFOODS, INC.VICTORIAN EPICURE INC.STIR FOODS LLCROBERTET CANADAATX SPECIALTY FOODSQUALIA SPECIALTY PROVISIONS
8FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb CartonBCFOODS, INC.VICTORIAN EPICURE INC.STIR FOODS LLCROBERTET CANADAATX SPECIALTY FOODSQUALIA SPECIALTY PROVISIONS
9FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb CartonBCFOODS, INC.VICTORIAN EPICURE INC.STIR FOODS LLCROBERTET CANADAATX SPECIALTY FOODSQUALIA SPECIALTY PROVISIONS
10FG-PPAN-052-002-P40Chile, Ancho Chile, Frozen Puree, Irradiated, 40 lb PailDEEN MEAT & COOKED FOODS
61
Copy & Pasting Customers


The results when I used your TRANSPOSE(FILTER formula:

CFarms Aged Inventory 8-21-24 for testing with customers.xlsx
CDVW
1Mini Sheet #4
2Item CodeItem NameCustomersCustomers2
3FG-PPAJ-040-000-C44Aji Amarillo, Ground , Untreated, 44.09 lb Carton#SPILL!
4FG-PPAJ-040-000-C44Aji Amarillo, Ground , Untreated, 44.09 lb Carton#SPILL!
5FG-PPAN-014-002-C25Chile, Ancho, Flake, Irradiated, 25 lb Carton#SPILL!
6Formula from Peter_SSsChile, Ancho, Flake, Irradiated, 30 lb Carton 
7FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb Carton#SPILL!
8FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb Carton#SPILL!
9FG-PPAN-014-003-C25Chile, Ancho, Flake, Steam Treated, 25 lb Carton#SPILL!
10FG-PPAN-052-002-P40Chile, Ancho Chile, Frozen Puree, Irradiated, 40 lb PailDEEN MEAT & COOKED FOODS
Formula from Peter_SSs
Cell Formulas
RangeFormula
V3:V10V3=TRANSPOSE(FILTER('2023-24 Sales thru August'!B:B,'2023-24 Sales thru August'!D:D=[@[Item Code]],""))
Named Ranges
NameRefers ToCells
'2023-24 Sales thru August'!_FilterDatabase='2023-24 Sales thru August'!$D$2:$D$2230V3:V10
 
Upvote 0
This may help.
View attachment 116046
In E3
Excel Formula:
=LET(a,A3:A9,au,UNIQUE(a),b,B3:B9,c,BYROW(au,LAMBDA(ro,TEXTJOIN("_",TRUE,FILTER(b,a=ro)))),d,TEXTSPLIT(TEXTJOIN(",",FALSE,c),"_",",",FALSE,0,""),HSTACK(au,IFERROR(VALUE(d),"")))

Hi, I couldn't get this to work at all. First of all, I have no idea what it is doing, you don't seem to be referencing individual cells (what do the a, b ,c, d, au, etc. in your formula represent?), and even when I set up your example and copied and pasted your formula into it, it did nothing, just posted a text version of the formula.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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