Excel Formula to Compare Two Sheets and Identify Duplicate Rows

📅 Aug 09, 2026 📝 Sarah Miller

Manually cross-referencing massive Excel datasets to identify duplicate rows is a tedious, error-prone struggle for busy analysts. While organizations often track departmental allocations across standard funding sources using basic, manual filters, scaling operations demand automated precision.

Implementing a robust, multi-criteria formula grants teams immediate, error-free visibility into cross-sheet redundancies. A key stipulation, however, is that both sheets must maintain identical column structures to prevent false negatives. For example, deploying a nested SUMPRODUCT or COUNTIFS formula to match range Sheet1!A2:C2 against Sheet2!A:C ensures absolute row alignment.

Below, we outline the exact formula syntax and step-by-step configuration to streamline your data auditing workflow.

Excel Formula to Compare Two Sheets and Identify Duplicate Rows

Managing large datasets across multiple Microsoft Excel worksheets is a routine task for data analysts, project managers, and administrators. One of the most common challenges is identifying matching or duplicate rows across two different sheets. Whether you are reconciling monthly financial reports, updating customer mailing lists, or merging inventory databases, finding duplicates is critical for maintaining data integrity.

While Excel provides a built-in "Remove Duplicates" tool, it operates primarily within a single sheet and lacks the flexibility needed to compare separate worksheets without altering your raw data. Fortunately, Excel formulas offer a dynamic, non-destructive way to compare two sheets. In this comprehensive guide, we will explore several powerful formulas to find duplicate rows, ranging from classic functions like COUNTIFS and VLOOKUP to modern dynamic arrays like XLOOKUP and FILTER.

Understanding the Scenario

Before writing our formulas, let's establish a standard scenario. Imagine we have two sheets in the same workbook:

  • Sheet1 (Current Month Data): Contains new entries that we need to check.
  • Sheet2 (Master Database): Contains historical records that we want to compare against.

Both sheets share a similar structure, with columns such as ID (Column A), First Name (Column B), Last Name (Column C), and Email Address (Column D).

---

Method 1: Comparing Single Columns using COUNTIF

If your rows can be uniquely identified by a single key column (such as a unique Customer ID or Email Address), you can use the straightforward COUNTIF function. This formula counts how many times a specific value from Sheet1 appears in the designated column of Sheet2.

The Formula:

=IF(COUNTIF(Sheet2!A:A, A2) > 0, "Duplicate", "Unique")

How It Works:

  1. COUNTIF(Sheet2!A:A, A2) searches the entire Column A of Sheet2 for the value located in cell A2 of your active sheet (Sheet1).
  2. If the value is found, the count will be 1 or greater.
  3. The IF statement checks if this count is greater than zero. If true, it returns "Duplicate"; otherwise, it returns "Unique".

Simply paste this formula into an empty column (e.g., Column E) on Sheet1 and drag the fill handle down to apply it to all rows.

---

Method 2: Comparing Entire Rows using COUNTIFS (Multi-Column Match)

In many real-world scenarios, a single column is not enough to declare a row a duplicate. For instance, two people might share the same first name, but their combination of First Name, Last Name, and Email must match to be considered a duplicate. To check multiple columns simultaneously, use COUNTIFS.

The Formula:

=IF(COUNTIFS(Sheet2!A:A, A2, Sheet2!B:B, B2, Sheet2!C:C, C2, Sheet2!D:D, D2) > 0, "Duplicate Row", "Unique")

How It Works:

The COUNTIFS function applies multiple criteria across different ranges. It will only return a count greater than 0 if all specified conditions are met on the exact same row in Sheet2:

  • Sheet2 Column A matches Sheet1 A2 (ID)
  • Sheet2 Column B matches Sheet1 B2 (First Name)
  • Sheet2 Column C matches Sheet1 C2 (Last Name)
  • Sheet2 Column D matches Sheet1 D2 (Email)

This method is highly robust and does not require you to sort your data before performing the comparison.

---

Method 3: Using XLOOKUP (Excel 365 & Excel 2021)

If you are using a modern version of Excel, XLOOKUP is a cleaner, more versatile alternative to traditional lookup formulas. You can use it to determine if a row exists in another sheet and pull corresponding status values.

The Formula:

=IF(ISNA(XLOOKUP(A2 & B2 & C2, Sheet2!A:A & Sheet2!B:B & Sheet2!C:C, Sheet2!A:A, "Not Found")), "Unique", "Duplicate")

How It Works:

This formula leverages concatenation (joining text strings with the & operator) to create a temporary, composite unique key:

  1. A2 & B2 & C2 combines the ID, First Name, and Last Name on Sheet1 into a single string (e.g., "101JohnDoe").
  2. Sheet2!A:A & Sheet2!B:B & Sheet2!C:C dynamically concatenates the matching columns on Sheet2.
  3. XLOOKUP looks up the combined string from Sheet1 within the combined array of Sheet2.
  4. If the value is not found, it returns `#N/A`. The ISNA wrapper catches this error and helps output "Unique" or "Duplicate" accordingly.

Note: Concatenating large ranges can cause performance slowdowns on slower computers or massive datasets exceeding 100,000 rows.

---

Method 4: Highlight Duplicates Visually with Conditional Formatting

If you prefer to see duplicate rows highlighted visually rather than typing formula flags in helper columns, you can use Excel's Conditional Formatting with a custom formula. This makes manual review quick and intuitive.

Step-by-Step Guide:

  1. Select the entire data range on Sheet1 (e.g., A2:D100).
  2. Go to the Home tab on the Ribbon.
  3. Click on Conditional Formatting > New Rule...
  4. Select "Use a formula to determine which cells to format".
  5. Enter the following formula (note the use of absolute column referencing with the $ sign to highlight the whole row):
    =COUNTIFS(Sheet2!$A:$A, $A2, Sheet2!$B:$B, $B2, Sheet2!$C:$C, $C2, Sheet2!$D:$D, $D2) > 0
  6. Click the Format... button, choose a fill color (like light red or yellow), and click OK.
  7. Click OK to apply the rule.

Now, any row on Sheet1 that has an exact duplicate in Sheet2 will instantly be highlighted.

---

Method 5: Extracting Only Duplicates with the FILTER Function

Instead of flagging or highlighting rows, what if you want to extract all duplicate records into a brand-new worksheet? If you are using Excel 365, the dynamic FILTER function can isolate these records automatically.

The Formula:

Enter this formula in cell A2 of a blank sheet:

=FILTER(Sheet1!A2:D100, ISNUMBER(MATCH(Sheet1!A2:A100 & Sheet1!B2:B100, Sheet2!A2:A100 & Sheet2!B2:B100, 0)))

How It Works:

  • MATCH searches for combined keys from Sheet1 in the combined keys of Sheet2. It returns a number representing the row index if a match is found, or `#N/A` if unique.
  • ISNUMBER converts these match results to logical TRUE (for matches/duplicates) or FALSE values.
  • FILTER streams all rows from Sheet1 where the matching condition evaluates to TRUE. This creates a dynamically updating list of duplicate rows.
---

Pro-Tips for Clean Comparisons

Formulas are exact, but human data entry is not. Minor differences in formatting can throw off your duplicate check. Keep these tips in mind to ensure accuracy:

  • Eliminate Invisible Spaces: Hidden trailing or leading spaces are the primary culprits for false negatives. Use the TRIM function inside your formulas (e.g., TRIM(A2)) to clean up whitespace.
  • Match Letter Case: By default, Excel formulas like COUNTIF and MATCH are case-insensitive. If "John" and "john" must be treated as duplicates, standard formulas work perfectly. If you require case-sensitive matches, utilize the EXACT function inside your comparisons.
  • Convert Formulas to Values: If you are working with extremely large spreadsheets (tens of thousands of rows), leaving dynamic lookup formulas active can slow down your workbook. Once your duplicate analysis is complete, copy the formula column and paste it as Values (Ctrl + Alt + V > Values) to freeze the results and optimize performance.

Conclusion

Comparing two worksheets for duplicates doesn't have to be a tedious, error-prone manual process. By choosing the right formula for your specific workbook structure-whether it's the quick COUNTIF, the comprehensive COUNTIFS, or modern arrays like FILTER and XLOOKUP-you can automate this workflow, save hours of manual review, and maintain spotless, reliable datasets.

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.