简体   繁体   English

查找并将唯一的多个值连接到一个单元格中

[英]Lookup and concatenate unique multiple values into one cell

I have the following table我有下表

Type类型 Item物品
Fruit水果 Banana香蕉
Veg蔬菜 Carrot萝卜
Fruit水果 Mango芒果
Fruit水果 Banana香蕉
Veg蔬菜 Lettuce生菜
Fruit水果 Banana香蕉
Fruit水果 Apples苹果
Fruit水果 Mango芒果

I want to look up the Type , in this case Fruit and return into a single cell, a list of unique Item 's.我想查找Type ,在本例中为Fruit并返回到单个单元格中,即唯一Item的列表。 For example, looking on up Fruit would return Banana; Mango; Apples例如,查找Fruit将返回Banana; Mango; Apples Banana; Mango; Apples Banana; Mango; Apples . Banana; Mango; Apples As you can see, we did not add the duplicate Banana 's and Mango 's如您所见,我们没有添加重复的BananaMango

I have tried the following, where D2 cell contains the type Fruit :我尝试了以下操作,其中D2单元格包含类型Fruit

=TEXTJOIN(" ", TRUE, IF(D2=A2:A9, B2:B9, ""))

I want to do this in pure excel, no VBA我想在纯 excel 中执行此操作,没有 VBA

Assuming you have Excel as part of the Office 365 package, you can achieve this using unique & filter (screenshot / this link refer):假设您将 Excel 作为 Office 365 包的一部分,您可以使用 unique & filter 实现这一点(屏幕截图/链接参考):

=TextJoin(",",True,UNIQUE(FILTER(C5:C12,B5:B12=F4)))

截屏

(modify True/False if you want blanks to appear; customize delimiter as desired) (如果要出现空格,请修改 True/False;根据需要自定义分隔符)

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

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