To compare rows in Excel for matches, the fastest method is a formula in a helper column that checks one row against another, for example =A2=B2 to compare two side-by-side cells, or =COUNTIF($A$2:$A$100,B2)>0 to check whether a value on one row exists anywhere in a list. Both return TRUE or FALSE, which you can then filter or highlight to see matches at a glance. Conditional formatting, the IF function for readable labels, and Power Query for large datasets are the other reliable ways to do the same job. The steps below cover each approach.

What You'll Need

  • Microsoft Excel on Windows, Mac, or the web app (labels and ribbon locations can differ slightly by version, platform, and region).
  • Your data laid out in rows, ideally with one header row and consistent columns.
  • An understanding of whether you are comparing two rows side by side (row by row) or looking for values from one row inside a longer list (lookup-style comparison). These need different formulas.
  • Optional: a clear empty column beside your data for helper results, so you can filter without disturbing the original values.

Step-by-Step

  1. Decide what counts as a match. Are you comparing entire rows across many columns, a single key column such as an order ID or email address, or just checking whether a value appears anywhere in another list? Whole-row comparisons need a formula per column or a concatenated key, while key-column comparisons are far simpler. Choosing wrong is the most common reason a comparison returns misleading results.
  2. Clean the data first. Matches fail when one cell contains John Smith and another contains john smith with a trailing space. Use TRIM to remove extra spaces and make comparisons case-insensitive where appropriate. TRIM is case-insensitive by nature; Excel comparisons are also case-insensitive unless you force otherwise with EXACT.
  3. Compare two cells in the same row. Click an empty cell beside the row, type =A2=B2, and press Enter. TRUE means the two values match, FALSE means they do not. Drag the fill handle down to apply the formula to every row.
  4. Compare a whole row across several columns. If you want to know whether row 2 and row 5 are identical on columns A to D, use =AND(A2=A5,B2=B5,C2=C5,D2=D5) or the shorter =COUNTIF(A2:D2,A2:D2)=4 in an array-aware version of Excel. For a single TRUE/FALSE across many columns, =TEXTJOIN("|",TRUE,A2:D2)=TEXTJOIN("|",TRUE,A5:D5) is often easier to read and edit.
  5. Check whether a value exists in another list. Put your lookup values in one column and the reference list in another. In a helper column type =COUNTIF($G$2:$G$200,A2)>0. A result of TRUE means that value appears at least once in the reference list. Wrap it in IF for friendlier output: =IF(COUNTIF($G$2:$G$200,A2)>0,"Match","No match").
  6. Use XLOOKUP or INDEX/MATCH when you need the matching row's value. =XLOOKUP(A2,$G$2:$G$200,$H$2:$H$200,"Not found") returns the corresponding value from a second column, and "Not found" makes misses obvious. In older Excel versions without XLOOKUP, use =IFERROR(INDEX($H$2:$H$200,MATCH(A2,$G$2:$G$200,0)),"Not found").
  7. Highlight matches with conditional formatting. Select the values you want to check, then go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter a rule such as =COUNTIF($G$2:$G$200,$A2)>0 and choose a fill colour. This colours every matching cell without adding a helper column. Menu wording may vary slightly between versions.
  8. Filter to review the results. Click your helper column header and use Data > Filter, then tick only TRUE or "Match". Filtering keeps the original data visible and works better than sorting because it does not reorder your rows.
  9. Turn the formulas into values if needed. If you plan to delete the reference list, select the helper column, copy it, then use Paste Special > Values so the results stay put. Otherwise they will turn into #REF! errors when the source data goes.
  10. For large or recurring comparisons, use Power Query. Go to Data > Get Data, load both tables, then use Home > Merge Queries. Choose the matching column in each table and pick the join type. A left anti join shows rows in one table that do not exist in the other; a full outer join shows both sides. This handles thousands of rows without slowing the sheet.

Common Mistakes

  • Comparing with the wrong relative reference. Formulas without dollar signs shift when dragged, so the range you compare against moves with each row and produces nonsense. Lock the reference list with $ signs.
  • Assuming TRUE means identical rows. =A2=B2 compares only those two cells. A whole-row check needs every column tested or a combined key.
  • Ignoring hidden characters. Text copied from websites or emails can contain non-breaking spaces that TRIM does not remove. Compare lengths with =LEN(A2) if two values look identical but fail to match.
  • Mixing text and numbers. A number stored as text (often shown with a small green triangle) will not equal a real number. Use VALUE or Number Stored as Text > Convert to Number from the warning menu.
  • Relying on case-sensitive matching without knowing. Excel's equals sign ignores case. If case matters, use =EXACT(A2,B2).

Tips

  • Build a single comparison key by joining fields, for example =A2&"|"&B2, then compare or look up that key. It is faster and less error-prone than comparing five columns.
  • Name your helper columns clearly, such as "In Master List" or "Duplicate Check", so future readers know what TRUE means.
  • Keep a backup copy before you sort or delete rows. Filtering and conditional formatting do not change data, but sorting and Paste Special can.
  • Use TRIM and PROPER in a staging column when names come from different systems, then compare the cleaned copies.
  • If you only need a visual check, conditional formatting is often quicker than a formula because it needs no new column.

Troubleshooting

If every row returns FALSE, check for leading or trailing spaces with TRIM and confirm that all values are the same data type. If only some rows fail, look for hidden characters, mixed text and numbers, or case differences. If you see #SPILL!, the formula needs empty cells around it; move it or move the blocking data. If you see #N/A from XLOOKUP or MATCH, the value genuinely is not in the list or the ranges are different sizes. If the sheet slows down badly, replace full-column references with exact ranges or move the comparison to Power Query. If matches look wrong after copying formulas, check whether dollar signs are missing. If conditional formatting highlights the wrong cells, make sure the rule's reference cell uses the right relative row number, such as A2 rather than $A$2 for the first row.

Frequently Asked Questions

Can I compare two columns and highlight duplicates?

Yes. Conditional formatting with a COUNTIF rule, or Excel's built-in Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values, will colour matching values in a selected column. The built-in option works within one column; for two columns, use a formula rule.

What is the difference between =A2=B2 and =EXACT(A2,B2)?

The equals sign ignores case and treats text and numbers loosely, so "ABC" equals "abc" in many cases. EXACT compares the values precisely, case included, and returns TRUE only if they are identical character for character.

How do I find rows that exist in one sheet but not another?

Use a COUNTIF against the other sheet, such as =COUNTIF(Sheet2!$A$2:$A$500,A2)=0, then filter for TRUE. This lists rows with no match on the second sheet. Power Query's anti join does the same for larger datasets.

Will these formulas work in Excel for the web?

Yes. COUNTIF, IF, TRIM, EXACT, conditional formatting, and filtering all work in the web app. Power Query and some array behaviours are more limited there, so use the desktop app for complex merges.

Why do identical-looking values not match?

The usual causes are trailing spaces, non-breaking spaces, numbers stored as text, or a value with a different case being compared with EXACT. LEN and TRIM reveal extra characters quickly.

Can I compare rows across two workbooks?

Yes, with formulas that reference the other workbook by name, for example =COUNTIF('[Book1.xlsx]Sheet1'!$A$2:$A$100,A2)>0. Keep both files open, because closed workbooks can make references slow or unreliable.