简体   繁体   English

Excel:在多列中查找具有重复项的多个值

[英]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.我的工作表中有 11 列的数据。 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:这里有一个小例子:

例子

I've made a helper column(A) using the following formula : =B2&COUNTIF($B$2:B2,B2) .我使用以下公式创建了一个辅助列 (A) : =B2&COUNTIF($B$2:B2,B2) The helper column counts how many time a product show up in the Products Column(B).辅助列计算产品在产品列 (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 :我设法使用=VLOOKUP($C$2&ROWS($L$1:L1),$A$2:$C$11,2,0)对数据进行了排序,如下所示:

Result结果

结果尝试

But I want to sort the data in a single Column for each store like this:但我想对每个商店的单个列中的数据进行排序,如下所示:

Desired Result想要的结果

想要的结果

, without having to change the formula every 2-3 rows, as some store have 30 or so products. ,而不必每 2-3 行更改一次公式,因为有些商店有 30 种左右的产品。

Is this something achievable with either formulas or VBA?这可以通过公式或 VBA 实现吗?

I would like to have the results in one column :我想在一列中得到结果:

  • List Store 1 items as many times as they appear in Product column. List 存储 1 个项目,它们出现在 Product 列中的次数。
  • If an item(from Store 1) doesn't show up in Product column show "Product name -"如果商品(来自商店 1)未出现在产品列中,则显示“产品名称 -”
  • Product Column can have repeatable items产品列可以有可重复的项目
  • Each store has different products, so there's no conflict there.每家店都有不同的产品,所以没有冲突。
  • If possible, since i have they Helper Column, if a product shows up 4 times, when i drag the formula in the 5th row it should jump to the next product.如果可能的话,因为我有他们的帮助列,如果一个产品出现 4 次,当我在第 5 行拖动公式时,它应该跳转到下一个产品。

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.第 1 列助手我添加了它来计算产品在第 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.我想要一个单独的列,它显示列 3(store1) 中的项目 x 它们在产品列中出现的次数。

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.在上面的示例中,Store1 的产品“Hansa”在产品列中出现了 4 次,因此它应该在单独的列中出现 4 次,之后产品“Korek”在产品列中出现了 1 次,因此它应该在产品列中出现一次“Hansa”下的单独列,依此类推。 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.所以基本上我想将第三列与第二列进行比较,并在第三个 x 次中显示它们出现在不同列中的第二列中的值。

This formula uses F1 as a helper cell , which is needed to count the matches in the product list.此公式使用F1作为辅助单元格,这是计算产品列表中的匹配项所必需的。

Enter this FormulaArray in F1 :F1输入这个FormulaArray

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

在此处输入图片说明

Enter this formula in E2:E11 :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 ) ) & "-", "" ) )

在此处输入图片说明

Note that the helper column A is not needed.请注意,不需要辅助列A

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM