How to Use COUNTIFS in Excel: Step-by-Step Guide
In this article
To put a COUNTIFS formula in Excel, type =COUNTIFS(range1, criteria1, range2, criteria2, ...) into a cell, replacing each range with the cells you want to check and each criteria with the condition those cells must meet. Press Enter and Excel returns the number of rows where every condition is true. COUNTIFS counts rows that satisfy all criteria at once, unlike COUNTIF which handles only one condition. Before you start, make sure your data is arranged in columns with a clear header row and that any numbers are stored as real numbers, not text.
What You'll Need
- Excel 2016 or later (desktop), Excel for Microsoft 365, or Excel for the web. The function works the same across these versions.
- A worksheet with data laid out in columns, one record per row.
- Consistent data types: dates stored as dates, numbers as numbers, text as text. Mixed types are the most common reason COUNTIFS returns 0.
- Optional: a small criteria area where you type the values you want to count, so you can change them without editing the formula.
Step-by-Step
- Pick the cell for your result. Click an empty cell where the count should appear, ideally outside your data range so the formula does not get overwritten.
- Start the formula. Type
=COUNTIFS(. Excel will show a tooltip listing the arguments: criteria_range1, criteria1, [criteria_range2, criteria2], …. Argument labels can differ slightly by version and region, but the order is always range, then criteria, repeated. - Enter the first range. Select the column you want to test, for example
B2:B100. Use the same number of rows in every range you supply; mismatched sizes cause a#VALUE!error. - Type a comma, then the first criteria. Criteria can be a number (
5), text in quotes ("North"), a cell reference (F2), or an expression in quotes (">100","<>Closed"). - Add more range/criteria pairs as needed. Each pair adds an AND condition. For example, to count orders in the North region over 100:
=COUNTIFS(B2:B100,"North",C2:C100,">100"). - Close the bracket and press Enter. Excel returns the count. If you see 0 when you expected a number, check data types first (see Troubleshooting).
- Test with a known value. Temporarily set one criterion to a value you can verify by eye, such as a single region name, and confirm the count matches a manual filter. This catches range misalignment early.
- Copy the formula down or across if needed. Use absolute references (
$B$2:$B$100) for the ranges so they do not shift when copied, and relative references for the criteria cell if you want each row to use its own value.
Common Mistakes
- Ranges of different sizes. Every criteria_range must cover the same number of rows.
B2:B100paired withC2:C90returns#VALUE!. - Forgetting quotes around text and operators.
"North"and">100"need quotes; a bare cell reference likeF2does not. - Using the wrong operator for "not equal". It is
"<>value", not"!=value". - Numbers stored as text. If a column was pasted from another system, values may look like numbers but be text. COUNTIFS with
">100"will not match them. Convert with Text to Columns or VALUE(). - Wildcards behaving unexpectedly.
*matches any sequence of characters and?matches one character. To search for a literal asterisk or question mark, precede it with a tilde:"~*". - Criteria that reference a blank cell. A blank criteria cell is treated as 0 for numeric comparisons and as an empty string for text, which can silently change the result.
- Using COUNTIFS when you need OR logic. COUNTIFS is AND-only. For OR conditions, add two COUNTIFS results together or use SUMPRODUCT.
Tips
- Use cell references for criteria so you can change the threshold without editing the formula. Name the cell (Formulas > Define Name) for readability.
- For date ranges, use
">="&DATE(2024,1,1)and"<"&DATE(2024,2,1)rather than typing dates as text, which avoids regional date-format mismatches. - Keep ranges as whole columns only when necessary; full-column references like
B:Bwork but slow large workbooks. Prefer a fixed range or an Excel Table with structured references. - If your data is in an Excel Table, structured references such as
Table1[Region]auto-expand as rows are added, so the count stays correct. - Combine COUNTIFS with a helper column when you need to count unique combinations; COUNTIFS alone counts rows, not distinct values.
- Press F2 to edit a formula in place, and use the formula bar's argument tooltip to check which range you are on.
Troubleshooting
- Result is 0 but data exists. Check for leading or trailing spaces in text criteria (use
TRIMon the source column or wildcards like"*North*"), and confirm numbers are not stored as text. Select the column and look at the status bar: if it shows Count but not Sum, the values are text. - #VALUE! error. Almost always mismatched range sizes. Select each range in the formula bar and confirm they cover the same rows.
- #NAME? error. A function name is misspelled or the formula uses a named range that no longer exists. Check Formulas > Name Manager.
- Criteria with wildcards not matching. Confirm the cell contains plain text, not a formula returning text with hidden characters. Use
LENto check for unexpected length. - Formula breaks when copied. Mixed absolute and relative references are the cause. Decide which parts should stay fixed and add
$accordingly. - Dates not counting. Dates may be stored as text. Use
DATEVALUEor re-enter them, then recheck the criteria syntax. - If that did not work, rebuild the formula one range/criteria pair at a time, testing after each addition. This isolates which pair is failing.
Frequently Asked Questions
What is the difference between COUNTIF and COUNTIFS?
COUNTIF takes one range and one criterion. COUNTIFS takes multiple range/criterion pairs and counts only rows where every condition is true.
Can COUNTIFS use OR logic?
Not directly. Add separate COUNTIFS formulas together, or use SUMPRODUCT with Boolean arrays for more complex OR conditions.
Does COUNTIFS work with dates?
Yes, provided the dates are stored as real dates. Use operators in quotes combined with DATE(), for example ">="&DATE(2024,1,1).
Why does my COUNTIFS return 0 for text that is clearly there?
Usually hidden spaces or a data-type mismatch. Wrap the criterion in wildcards ("*text*") to test, and clean the source column with TRIM.
Can I use COUNTIFS across multiple sheets?
Yes, but each range must be on a single sheet and referenced with the sheet name, for example Sheet2!B2:B100. Ranges cannot span sheets inside one argument.
Is COUNTIFS case-sensitive?
No. COUNTIFS ignores case for text criteria. For case-sensitive counts, use SUMPRODUCT with EXACT.