简体   繁体   English

比较两个Excel的两列并返回第三列

[英]Compare two columns of two excels and return 3rd column

I want to compare two columns of two different Excel sheets and return the corresponding 3rd column value of 2nd excel sheet infront of corresponding matched rows of 1st excel sheet. 我想比较两个不同的Excel工作表的两列,并返回第一张Excel工作表的相应匹配行前面的第二张Excel工作表的相应第三列值。

Suppose Excel 1 contains follow value 假设Excel 1包含跟随值

Sl.No   Count
-------------------------------
105       1  
106       2  
107       3  
108       4  
109       5  
110       6  

Excel 2 contain Excel 2包含

Sl.No   Count   Grade
-----------------------
108       4       A  
109       5       B  
110       6       C  
111       1       D  

Expected result 预期结果

Sl.No   Count   Grade
-------------------------
105       1  
106       2 
107       3 
108       4       A  
109       5       B  
110       6       C  

Please suggest, what function should I use. 请提出建议,我应该使用什么功能。

Thanks in Advance. 提前致谢。

Use this formula: 使用以下公式:

=IFERROR(IF(VLOOKUP(A2,'Excel 2'!$A$2:$B$1000,2,FALSE)=B2,VLOOKUP(A2,'Excel 2'!$A$2:$C$1000,3, FALSE),""),"")

Put it into Cell C2 in your first sheet and fill down. 将其放入第一张工作表的Cell C2中并填写。

Another formula option is below. 下面是另一个公式选项。 A bit cleaner, but it's an array formula, so processing may be slower with large data sets. 稍微干净一点,但是它是一个数组公式,因此对于大数据集,处理可能会变慢。

=IFERROR(INDEX(Sheet2!C:C,MATCH(A1&B1,Sheet2!A:A&Sheet2!B:B,0)),"")

It's an array formula, so be sure to press Ctrl + Shift + Enter when exiting edit mode. 这是一个数组公式,因此请确保在退出编辑模式时按Ctrl + Shift + Enter If done right, excel will wrap curly brackets around the formula. 如果操作正确,excel将在公式周围使用大括号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM