The COUNTIF function in Excel is a powerful tool designed to help users tally the number of cells that meet certain criteria within a defined range. This function is particularly useful for analyzing data sets, allowing users to quickly quantify the information they need based on specific conditions.
Syntax
COUNTIF(range, criteria)
- range: The group of cells you want to evaluate.
- criteria: The condition that defines which cells will be counted.
Example #1
=COUNTIF(A1:A10, ">=50")
This function counts all the cells in the range A1 to A10 that have values greater than or equal to 50. For instance, if the values are {45, 67, 82, 50, 32, 90, 55, 49, 70, 40}, the result would be 5 since five cells meet the condition.
Example #2
=COUNTIF(B1:B100, "Apples")
This example counts the number of times “Apples” appears in the range from B1 to B100. If the range contains the values {Bananas, Apples, Oranges, Apples}, the result would be 2.
Example #3
=COUNTIF(C1:C20, "<=100")
This function counts all cells in the range C1 to C20 where the value is less than or equal to 100. If the values are {150, 60, 110, 90, 85, 30, 75}, the result will be 5 as five values meet the condition.
Error handling
- VALUE! This error appears if the range or criteria are supplied with invalid data types.
- NAME? This indicates that the function name has been misspelled, or Excel does not recognize it.
- REF! This error occurs when the specified range does not exist, possibly due to deleted rows or columns.