misc15
misc15

Reputation: 35

Excel: Lookup Multiple values with duplicates in multiple columns

I'm trying to link multiple lists and show all the values. Including duplicates.

My worksheet has data in 11 Columns. One column with Products(which can appear multiple times) and the rest with Store(which sell the products, no store sells the same product). A small example here:

Example

I've made a helper column(A) using the following formula : =B2&COUNTIF($B$2:B2,B2) . The helper column counts how many time a product show up in the Products Column(B). I thought it was needed.

I've managed to sort the data a bit using =VLOOKUP($C$2&ROWS($L$1:L1),$A$2:$C$11,2,0) like this :

Result

Result Attempt

But I want to sort the data in a single Column for each store like this:

Desired Result

Desired Result

, without having to change the formula every 2-3 rows, as some store have 30 or so products.

Is this something achievable with either formulas or VBA?

I would like to have the results in one column :

Hope this is clear enough. Thank you

Later Edit:
Maybe this helps a bit in understanding what I want to obtain.

Column 1 helper I've added it to count how many times a product shows up in Column 2.
I want to get a separate column, which shows the items in Column 3(store1) x how many times they appear in Products Column.

In the example above Store1 has product "Hansa" which appears 4 times in Product Column so it should appear 4 times in the separate column, after it there's product "Korek" which appears 1 time in Product Column so it should appear one time in the separate column under "Hansa" and so on. So basically I want to compare the third column to the second and show to values in the third x times they appear in the second in a different column.

Upvotes: 1

Views: 587

Answers (1)

EEM
EEM

Reputation: 6659

This formula uses F1 as a helper cell, which is needed to count the matches in the product list.

Enter this FormulaArray in F1:

=SUM( IF( ISERROR( MATCH( $B$2:$B$11, $C$2:$C$6, 0 ) ), 0, 1 ) )

enter image description here

Enter this formula in E2:E11:

= IFERROR( INDEX( $C$2:$C$6,
AGGREGATE( 15, 6,
MATCH( $B$2:$B$11, $C$2:$C$6, 0 ),
ROWS( E$2:E2 ) ) ),
IFERROR( INDEX( $C$2:$C$6,
AGGREGATE( 15, 6,
ROW(E:E) / ISERROR( MATCH( $C$2:$C$6, $B$2:$B$11, 0 ) ),
ROWS( E$2:E2 ) - $F$1 ) ) & "-", "" ) )

enter image description here

Note that the helper column A is not needed.

Upvotes: 1

Related Questions