You are on page 1of 1

How to compare two columns in

Excel for matches and differences


Suppose you have 2 lists of data in Excel, and you want to find all values (numbers,
dates or text strings) which are in column A but not in column B.

For this, you can embed the COUNTIF($B:$B, $A2)=0 function in IF's logical test and
check if it returns zero (no match is found) or any other number (at least 1 match is
found).

For instance, the following IF/COUNTIF formula searches across the entire column B
for the value in cell A2. If no match is found, the formula returns "No match in B",
an empty string otherwise:

=IF(COUNTIF($B:$B, $A2)=0, "No match in B", "")

Tip. If your table has a fixed number of rows, you can specify a certain range (e.g.
$B2:$B10) rather than the entire column ($B:$B) for the formula to work faster on
large data sets.

You might also like