COUNTIF() – Counts cells in a range that meet a specified condition
The COUNTIF() function counts the number of cells within a range that satisfy a given criterion or condition.
Syntax
COUNTIF(range, "condition")
range: The range of cells where you want to evaluate the condition and count the cells that meet it (e.g., T1A1:T1A10).
condition: The criterion in the form of a number, expression, or text that defines which cells will be counted. It must be enclosed in double quotes (e.g., ">50", "TextValue", "<=0").
Basic example
COUNTIF(T1A1:T1A10, ">50")
This formula counts how many cells in the range T1A1:T1A10 contain numbers greater than 50.
Example outputs:
- If cells T1A1:T1A10 contain [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]:
COUNTIF(T1A1:T1A10, ">50") → 5 (counts 60, 70, 80, 90, 100) - If cells T1A1:T1A5 contain [5, "Text", 15, 0, 10]:
COUNTIF(T1A1:T1A5, "<10") → 2 (counts cells containing 5 and 0).
COUNTIF(T1A1:T1A5, "==15") → 1 (counts cells equal to 15).
COUNTIF(T1A1:T1A5, "Text") → 1 (counts cells containing "Text").
Supported operators for conditions
Conditions use standard comparison operators:
• > (greater than)
• >= (greater than or equal to)
• < (less than)
• <= (less than or equal to)
• == (equal to)
• != (not equal to)
Key features
- Conditional counting: Counts only those cells in the range that meet the specified condition.
- Single range: The same range is used for evaluating the condition.
- Counts various data types: Can count cells containing numbers or text that match the condition. Empty cells are generally not counted by a direct value condition unless the condition specifically targets emptiness (e.g., "").
Practical uses
- Counting sales figures that exceed a certain target value.
- Counting expenses for items that are less than or equal to a specific budget amount.
- Counting scores that are above an average or pass mark.
Common mistakes
- Condition not in quotes: The condition argument must always be enclosed in double quotes (e.g., use ">50").
- Numbers formatted as text: If the condition is numeric (e.g., ">50"), cells containing numbers formatted as text will not be counted.
MathGrid ©
MathGrid ©