Cocoa Dev
Cocoa Dev

Reputation: 9541

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)

Upvotes: 0

Views: 190

Answers (2)

rajah9
rajah9

Reputation: 12329

I think VLookup will do the trick for you.

I had Sheet2 with the following in A1:A6:

SerNo
1001
1002
1003
1004
1005

Then on the next sheet I had similar, but not identical numbers in 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. 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. (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.)

(Instead of $A$2:$A$6, you could also make this a named range, which I think would be a bit cleaner.)

The VLookup column has:

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

and shows where there are matches (and where there are not).

Upvotes: 2

JDunkerley
JDunkerley

Reputation: 12495

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

This formula returns true if A1 is in the Sheet1 list

Upvotes: 1

Related Questions