[英]Compare data in two columns and print difference in 3rd column
In excel I am looking to do the following: 在excel中,我希望执行以下操作:
If a value in "Column B" exists anywhere in "Column A", print said value to "Column C" 如果“列B”中的值存在于“列A”中的任何位置,请将该值打印到“列C”中
and 和
If a value exists in "Column B" and does not exist in "Column A", print said value to "Column D" 如果“列B”中存在一个值,而“列A”中不存在该值,则将该值打印到“列D”中
So.. 所以..
In a sheet where, 在工作表中
"Column A" has: 1, 2, 3, 4
“列A”具有: 1, 2, 3, 4
"Column B" has: 1, 3, 5
“ B列”具有: 1, 3, 5
I want, 我想要,
"Column C" to populate " 1
" and " 3
" “ C列”填充“ 1
”和“ 3
”
"Column D" to populate " 5
" “ D列”填充“ 5
”
- A B C D
- 1 1 1 5
- 2 3 3
- 3 5
- 4
Simply use IF()
formula and fill down: 只需使用IF()
公式并填写:
| A | B | C | D |
1| 1 | 1 |=IF(COUNTIF($A$1:$A$4,B1)>0,IF(ISBLANK(B1),"",B1),"")|=IF(COUNTIF($A$1:$A$4,B1)=0,IF(ISBLANK(B1),"",B1),"")|
2| 2 | 3 |
3| 3 | 5 |
4| 4 | |
Then result will be like this: 然后结果将是这样的:
| A | B | C | D |
1| 1 | 1 | 1 | |
2| 2 | 3 | 3 | |
3| 3 | 5 | | 5 |
4| 4 | | | |
If you want them to appear without spaces, try 如果希望它们显示为无空格,请尝试
=IFERROR(INDEX($B$1:$B$3,SMALL(IF(COUNTIF($A$1:$A$5,$B$1:$B$3),ROW($B$1:$B$3)),ROW())),"")
and 和
=IFERROR(INDEX($B$1:$B$3,SMALL(IF(COUNTIF($A$1:$A$5,$B$1:$B$3)=0,ROW($B$1:$B$3)),ROW())),"")
Both of these are array formulae and must be entered with Ctrl Shift Enter 这两个都是数组公式,必须使用Ctrl Shift 输入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.