问题
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!
回答1:
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 :) ).
回答2:
Try this:
=COUNTIF(C16:BT16;BU18)
Please note that you may need to use ";" instead of "," depending on your region.
回答3:
If you are using Excel 2010, you are even luckier with COUNTIFS
By all means you may use the search range and matching range within countif
e.g.
=COUNTIF(SEARCH RANGE, CRITERIA RANGE)
来源:https://stackoverflow.com/questions/13978701/count-number-of-cells-in-a-range-that-match-the-content-of-a-different-cell