且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

查找,匹配和连接

更新时间:2021-09-26 15:52:05

您可以使用函数来逐步完成各个步骤.从UNIQUE功能开始.将其放在方便列出B列的所有唯一值的单元格中:

You can go through a process of steps using functions. Start with the UNIQUE function. Put this in a cell where it is convenient to list all the unique values of column B:

=UNIQUE(B:B)

获取列B中的所有唯一值. Google支持-唯一功能

Gets all the unique values in column B. Google Support - Unique Function

UNIQUE函数的结果将如下所示:

The result from the UNIQUE function will look like this:

现在您已拥有B列中的所有唯一值,则可以使用FILTER函数检索与该唯一值匹配的所有行.

Now that you have all the unique values from column B, you can use the FILTER function to retrieve all the rows that match that unique value.

=FILTER(D1:D6, B1:B6=A8)

FILTER函数将所有结果列在该列下,但是您可以使用CONCATENATE函数来避免这种情况.

The FILTER function lists all the results down the column, but you can use the CONCATENATE function to avoid that.

FILTER函数的结果:

Results of FILTER function:

CONCATENATE的结果:

Results of CONCATENATE:

您将需要调整FILTER函数以现在使用D列而不是C列.

You will need to adjust the FILTER function to now use column D, rather than column C.

=CONCATENATE(FILTER(D1:D6, B1:B6=A8))

这解决了获取多行数据的问题,但是现在值之间没有分隔符.

This solves the problem of getting data in multiple rows, but now there is no separator between the values.

要解决该问题,您可以创建第四列,并在其末尾添加一个逗号函数:

To get around that problem, you can create a fourth column with a function that adds a comma to the end:

最后有一个多余的逗号问题,您可以使用LEFT函数将其消除:

There is a problem with an extra comma on the end, which you can get rid of with the LEFT function: