Count number of cells in a range that match the content of a different cell

Gene Barrett picture Gene Barrett · Dec 20, 2012 · Viewed 81.1k times · Source

I am trying to use COUNTIF in Excel to find how many items in a range match the contents of a separate cell. The idea is, the range contains everyone's answers to a given question (a one-word, non-numeric answer); the comparison column contains the correct answer. I want a count of how many people got the answer correct.

I tried: =COUNTIF(C16:BT16,"=BU16")

But it appears COUNTIF won't let me reference a cell with the criteria in it -- it requires the match criteria directly in the formula, such as =COUNTIF(C16:BT16,"DEN"). I can do that, of course, but I'd have to edit dozens of formulas every time I evaluate answers, and it would be much less timeconsuming if I could just enter the answers in column BU.

I also tried COUNTIFS; it allows multiple criteria, but also doesn't allow referencing the criteria to a different cell. Searched several different Excel websites too, any suggestions? Many thanks!

Answer

RocketDonkey picture RocketDonkey · Dec 20, 2012

Try removing the quotes and equal sign from "=BU18" - that will indicate that you are passing the value at that cell, which I believe is what you're looking for.

=COUNTIF(C16:BT16,BU18)

Assuming BU18 contains DEN. Your first example ("=BU18") is saying "count if any of these cells have a value of "=BU18", which won't match anything (unless they answered some weird questions :) ).