Count matching values in 2 columns

Viewed 149

How can I count matching values in 2 columns?

I've tried using this formula: =SUMPRODUCT(--(B1:B5=C1:C3))

enter image description here

But I'm having #N/A. I should get a value 3.

2 Answers

Try the following:

=SUMPRODUCT((COUNTIF(B1:B5,C1:C3)>0)+0)

Adapted from @BarryHoudini

It would count the total of exact value, base on lookup column.

For the answer how to get your result you can check QHarr's answer.

Now on your error.

First: If you want the formula to work, you need the two ranges to have the same length so it should be: =SUMPRODUCT(--(B1:B5=C1:C5)) and not C1:C3

Second: I guess you found your formula from the question: Count matches between two columns. However, there is a main difference between your two sets of data.

In this question the same words are on the same row, in yours, only the a is on the same row on both columns. The point of the formula the way you wrote it, is to find the matches between the two columns according to their row number. So the result you should get with this formula will be 1.

Related