如果单元格中的值与另一个单元格中的值相似,则将它们连在一起。

问题描述 投票:2回答:1

我需要把一个人去过的城市名称连接到另一个单元格中,但每次出现这个人的名字时都要重复。我试过使用COUNTIF,但没有任何效果。

我不想用VB代码,只想用公式函数。有什么好办法吗?

enter image description here

下面是我的电子表格的链接。

google-sheets google-sheets-formula array-formulas google-sheets-query gs-vlookup
1个回答
2
投票

使用:

=ARRAYFORMULA(REGEXREPLACE(IFNA(VLOOKUP(B2:B, 
 TRIM(SPLIT(TRANSPOSE(TRIM(QUERY(QUERY({A2:A&",", B2:B&"♦"},
 "select max(Col1) where Col1 <> ',' group by Col1 pivot Col2")
 ,,99^99))), "♦")), 2, 0)), ",$", ))

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.