# Count cells that match?

#### meredithsegal

##### New Member
I have data in C2:C14 and D2:D14. I want Excel to count the number of instances in which the value in column C matches the value in that row in column D. What's the easiest way?

Thanks so much--you guys are always awesome!

### Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Try

=SUMPRODUCT(--(C2:C14=D2:D14))

Awesome, why does it work tho?

Awesome, why does it work tho?

Because I told it to.

It creates an array of True or False results based on the expression C2:C14=D2:D14.
Evaluating each row 1 at a time, does C2 = D2 ? Does C3 = D3?
With a True or False result for each row

The -- converts those True/False results into 1/0 results (True = 1, False = 0)
Then it sums the results.

(and how can I amend it only to consider cells with a given value in column A -- how to add (countif(A2:A14,"apple"))

(and how can I amend it only to consider cells with a given value in column A -- how to add (countif(A2:A14,"apple"))

Try
=SUMPRODUCT(--(A2:A14="apple"),--(C2:C14=D2:D14))

You're awesome--would you like a job?

Glad to help, thanks for the feedback.

Replies
25
Views
526
Replies
8
Views
370
Replies
3
Views
229
Replies
5
Views
201
Replies
13
Views
640

1,211,452
Messages
6,101,940
Members
447,764
Latest member
gopalgriffith

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back