# Comparing Lists for Duplicates

by Allen Wyatt
(last updated January 27, 2016)

Imagine for a moment that you have a worksheet that contains lists of part numbers. On one worksheet you have a list of part numbers, and on another worksheet you have a similar list. The lists are not identical, however, and you want to determine if a particular part number on one list also appears on the other.

One solution is to somehow combine the lists, but add some sort of indicator as to which original list the particular part number came from. This approach (or a variation thereon) is, in fact, the approach taken by many Excel users.

What if you don't want to combine the lists, however? In this case, there is a very easy way to do the comparison. Follow these steps:

1. Make sure there is a blank column just to the right of each list of part numbers on each worksheet.
2. Select the part numbers on the first worksheet and give them a name such as "PartList1". (Use Insert | Name | Define.)
3. Select the part numbers on the second worksheet and give them a name such as "PartList2".
4. Assuming that the first part number on the first worksheet is in cell A2, enter the following formula in cell B2:
```     =ISNUMBER(MATCH(A2,PartList2,0))
```
1. Copy the formula down so that a copy appears to the right of each part number on the first worksheet.
2. Repeat steps 4 and 5 on the second worksheet, but use the following formula:
```     =ISNUMBER(MATCH(A2,PartList1,0))
```

When you are done, either TRUE or FALSE will appear to the right of each part number on each worksheet. If TRUE appears, the associated part number appears on the other worksheet. If FALSE appears, then the part number is unique and does not appear on the other worksheet.

Another approach is to use an array formula to do the comparisons. You could follow the same steps shown above, but use the following formula in step 4 (and PartList1 variation in step 6):

```=OR(EXACT(A2,PartList2))
```

Since this is an array formula, you would enter it by using Shift+Ctrl+Enter. The result is the same TRUE and FALSE designation described above.

Regardless of which formula approach you use, you can use the AutoFilter capabilities of Excel to limit what is shown on either worksheet. If you filter to show only the FALSEs, you will have a list of all unique part numbers. If you filter to show TRUEs, then you will have a list of duplicates.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2251) applies to Microsoft Excel 97, 2000, 2002, and 2003.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Preventing Someone from Recreating a Protected Worksheet

When you share a protected workbook with other people, you may not want them to get around the protection by creating a ...

Discover More

Finding the Date Associated with a Negative Value

When working with data taken from the real world, you often have to determine which certain conditions were met, such as ...

Discover More

Does your keyboard seem a bit sluggish or a bit too quick when you hold down keys? You can adjust how the keyboard ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

Searching a Workbook by Default

When you display the Find tab of the Find and Replace dialog box, you'll notice that any search, by default, will be on ...

Discover More

Turning Off Speech Capabilities

Excel can talk to you, reading back whatever you enter into a cell. If you want to turn this capability off, you'll want ...

Discover More

Using List Box Controls

List boxes can be a great tool for getting input from users of your worksheets. This tip describes what list boxes are ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two minus 1?

2019-02-20 17:46:40

J Bingham

I struggled to get this to work until I found two errors that were keeping it from working.
First, it is not sufficient to just place the name of the range in the formula when the range is in a different file, the name of the file must also be included in the formula, i.e. =ISNUMBER(MATCH(A2,'SecondPartListfile.xls'!PartList2,0)).
The second error was in my data, I was trying to compare numbers stored as text to numbers.
Once I corrected both these errors, this worked like a champ.

##### This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.