比较 Excel 中的两列并排除
I want to compare values in two columns in Excel as depicted in the image below :-
Using the formula, I want to put the values in the "Values of A which don't exist in B" and "Values of B which don't exist in A". Any help is appreciated.
I have shared the same excel sheet here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下内容将起作用 - 对于每个,在第 2 行中添加公式,然后向下拖动
B 中不存在的 A 值
结果 = x, y, z, i, j ,k, l, u
注意:您的示例电子表格不正确,因为 u 在 A 列中,但不在 B 列中,但您没有将其列在 C 列的结果集中
A 中不存在的 B 值
结果 = q、r、e、f、g
The following will work - for each, add the formula in row 2 and then drag down
Values of A that do not exist in B
Result = x, y, z, i, j ,k, l, u
NB: Your example spreadsheet is incorrect as u is in Col A but not Col B but you do not list it in your result set in Col C
Values of B that do not exist in A
Result = q, r, e, f, g
您也可以使用高级过滤器来做到这一点
假设 A 列和 B 列中的数据
在单元格 C2 中写入 =SUMPRODUCT(--($B$2:$B$17=A2))=0
选择数据A1:A12
单击高级过滤器,选择复制到另一个位置
列表范围 = $A$1:$A$22
标准范围 = $C$1:$C$2 (注意 C1 为空)
在“复制到范围”中选择“E1”,单击“确定”
这将为您提供 B 中不存在的 A 值
在单元格 D2 中写入 =SUMPRODUCT(--($A$2:$A$22=B2))=0
选择数据 B1:B17
单击高级过滤器,选择复制到另一个位置
列表范围 = $A$1:$A$22
标准范围 = $D$1:$D$2 (注意 D1 为空)
在复制到范围中选择 F1,说确定
这将为您提供 A 中不存在的 B 值
您可以通过单行代码
Sub Get_Data1()
[List1].AdvancedFilter 2, [Crt1], [Dest1], True
End Sub
Sub Get_Data2()
[List2 ].AdvancedFilter 2、[Crt2]、[Dest2]、True
End Sub
You can also do this with Advance Filter
Assuming Data in Col A and B
In Cell C2 write =SUMPRODUCT(--($B$2:$B$17=A2))=0
Select Data A1:A12
Click on Advanced Filter, Choose copy to another location
List Range = $A$1:$A$22
Criteria Range = $C$1:$C$2 (Note C1 to be blank)
In Copy to Range choose E1, Say OK
This will give you Values of A that don't exist in B
In Cell D2 Write =SUMPRODUCT(--($A$2:$A$22=B2))=0
Select Data B1:B17
Click on Advanced Filter, Choose copy to another location
List Range = $A$1:$A$22
Criteria Range = $D$1:$D$2 (Note D1 to be blank)
In Copy to Range choose F1, Say OK
This will give you Values of B that dont exist in A
You can automate this Via a single line of Code
Sub Get_Data1()
[List1].AdvancedFilter 2, [Crt1], [Dest1], True
End Sub
Sub Get_Data2()
[List2].AdvancedFilter 2, [Crt2], [Dest2], True
End Sub