Excel:对Excel中的数据进行分组重组

Excel: Grouping and restructuring data in Excel

在 Excel 中,我想将顶部的 table(初始数据)转换为底部的 table(所需输出)。 我想按第一行对第二行中的项目进行分组,然后为第一行的每个唯一值生成一列,并在该列中列出相应组的项目。

有没有不用手动复制单元格的方法?

Table:初始数据

Fruit Banana
Fruit Apple
Fruit Grape
Vegetable Spinach
Vegetable Eggplant

Table:期望的输出

Fruit Vegetable
Banane Spinach
Apple Eggplant
Grape

如果您有权访问 UNIQUEFILTER 函数 (Excel 365),您可以按如下方式完成此操作。

假设您的数据在 A1:B5 中。在 D1 中输入:

=TRANSPOSE(UNIQUE($A:$A))

这将为您提供 D1:E1A 中单元格的唯一值。然后在D2中输入:

=FILTER($B:$B,$A:$A=D1)

并向右拖动。

即你这样做:

结果: