问题
I have two columns in excel that have some shared data and some unique data to each column. What I want is to have two more columns that will have the data that is in Column A but not B and the data that is in Column B but not in A. I have tried using Vlookups but I don't think I can get what I am looking for by doing this.
回答1:
For Col A items not in column B, try this array-entered formula (entered in some cell, then fill down until it returns blanks)
=IFERROR(INDEX(ColA,SMALL(IF(ISNA(MATCH(ColA,ColB,0)),ROW(ColA),""),ROWS($1:1))-1),"")
and for Col B items not in Column A:
=IFERROR(INDEX(ColB,SMALL(IF(ISNA(MATCH(ColB,ColA,0)),ROW(ColB),""),ROWS($1:1))-1),"")
The formulas assume that your data starts in row 2 (row 1 would be a label) and the ranges ColA and ColB also start in Row 2
The formulas also assume no blanks in the data. If there are empty cells, then use these formulas:
=IFERROR(INDEX(ColA,SMALL(IF(ISNA(MATCH(ColA,ColB,0))*(ColA<>""),ROW(ColA)),ROWS($1:1))-1),"")
=IFERROR(INDEX(ColB,SMALL(IF(ISNA(MATCH(ColB,ColA,0))*(ColB<>""),ROW(ColB)),ROWS($1:1))-1),"")
Example Image:

回答2:
Easy with a PivotTable, if you are prepared to rearrange your data somewhat:

来源:https://stackoverflow.com/questions/21686456/finding-elements-that-are-unique-in-one-column-excel