Excel - Filter unique values from Column A and move related values from Column B to other columns

杀马特。学长 韩版系。学妹 提交于 2020-01-16 01:01:10

问题


I have a excel like this

Col1 - Col2
A - 1
B - 2
A - 3
B - 4
A - 5

I want to produce an excel from above one as shown below

Col1 - Col2 - Col3 - Col4
A - 1 - 3 - 5
B - 2 - 4

Is there a way in excel to do this?

Please help


回答1:


Here's a way to do it with formulas. It takes a small bit of formatting first though, so perhaps copy your data to a new sheet, then tweak.

First, get the unique values from Column A. In your example, these would be A and B. (For long lists, copy column A to some random column. Select that column, go to Data--> Remove Duplicates. This will give you your unique list).

After you have the list, place it in Column D (for example). Then, enter this formula as an array in column E (enter with CTRL+SHIFT+ENTER):

=IFERROR(INDEX($B$1:$B$6,SMALL(IF($A$1:$A$6=$D1,ROW($A$1:$A$6)-ROW($A$1)+1),ROWS(INDIRECT("$A$1:A"&COLUMN()-4)))),"")

A couple notes: Adjust the range from rows 1 to 6 as necessary. Also, if you choose a column other than column E to put this in, adjust the Column()-4 part at the end so that the column number minus the other number (in my example, 4) equals 1. (In my formula the Column() returns 5 (for "E") and 5-4=1.

You can then drag over, and down, and it should work.



来源:https://stackoverflow.com/questions/34050387/excel-filter-unique-values-from-column-a-and-move-related-values-from-column-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!