简体   繁体   English

用于查找匹配项的Excel公式

[英]Excel Formula for finding matches

I have two worksheets 我有两个工作表

In one worksheet, I have a column called Serial Number 在一个工作表中,我有一列称为序列号

The second worksheet also has a column for serial number 第二个工作表也有一个序列号列

The two worksheets have overlapping data and I need to find the ones that are found in both worksheets. 这两个工作表的数据重叠,因此我需要找到两个工作表中都存在的数据。

Any suggestions for the formula that I would need to use? 对我需要使用的公式有什么建议吗? (VBA code is also acceptable) (也可以使用VBA代码)

I think VLookup will do the trick for you. 我认为VLookup将为您解决问题。

I had Sheet2 with the following in A1:A6: 我在A1:A6中使用了Sheet2,其中包含以下内容:

SerNo
1001
1002
1003
1004
1005

Then on the next sheet I had similar, but not identical numbers in A1:A6: 然后在下一张纸上,我在A1:A6中有相似但不相同的数字:

Serno
1003
1005
99
98
97

In B2, I used the formula =VLOOKUP(A2,Sheet2!$A$2:$A$6,1,FALSE) and copied it down to B6. 在B2中,我使用公式=VLOOKUP(A2,Sheet2!$A$2:$A$6,1,FALSE)并将其复制到B6。 What this means is: Look up the value in A2 (1003) and see if you can find it on Sheet2 in cells A2 through A6. 这意味着什么:在A2(1003)中查找值,看看是否可以在Sheet2的A2到A6单元格中找到它。 (The $A$2:$A$6 means absolute and when I copy B2 to B6 it keeps the reference absolute at the Sheet2 Serno and does not shift them down. The 1 means use the first column, the serial number. The FALSE means you must have an exact lookup.) $A$2:$A$6表示绝对值,当我将B2复制到B6时,它将参考绝对值保留在Sheet2 Serno上,并且不会向下移动。1表示使用第一列,即序列号。FALSE表示您必须有确切的查询。)

(Instead of $A$2:$A$6 , you could also make this a named range, which I think would be a bit cleaner.) (除了$A$2:$A$6 ,您还可以将其命名为一个范围,我认为这样会更干净一些。)

The VLookup column has: VLookup列具有:

1003
1005
#N/A
#N/A
#N/A

and shows where there are matches (and where there are not). 并显示哪里有匹配项(哪里没有)。

You could use something like 您可以使用类似

=NOT(ISERROR(MATCH(A1,Sheet1!$A$1:$A$4,0)))

Where the serial numbers on Sheet1 are in Cella A1:A4 and the serial numbers on the second sheet are in cell A1 在Sheet1上的序列号在单元格A1:A4中,第二张工作表上的序列号在单元格A1中

This formula returns true if A1 is in the Sheet1 list 如果A1在Sheet1列表中,则此公式返回true

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

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