How to Countif Function in Excel

Learn multiple Excel methods to Countif Function with step-by-step examples and practical applications.

excelformulaspreadsheettutorial
12 min read • Last updated: 7/2/2025

How to Countif Function in Excel

Why This Task Matters in Excel

In every spreadsheet you build—whether it is a sales tracker, a project dashboard, or a payroll register—it never takes long before you have to count how many entries meet a particular condition. Managers want to know how many sales reps beat quota, HR asks how many employees are eligible for overtime, and operations needs the number of orders waiting to be shipped. Counting filtered by criteria is so common that failing to master it slows down virtually every analytical workflow.

Imagine an e-commerce analyst who receives a customer order sheet every morning. To forecast shipping capacity, the analyst must quickly answer questions such as:

  • How many orders are marked “Express Shipping”?
  • How many orders were placed in March?
  • Within those, how many are valued greater than $200?

The faster the analyst can answer these, the quicker the warehouse can prioritize picking and packing. The same principle appears in finance (count invoices overdue), education (count students with test scores above 90), healthcare (count patients scheduled this week), and countless other industries.

Excel is particularly well-suited for this task because:

  1. It stores data in a tabular grid, ready for range-based functions.
  2. It provides built-in aggregation functions like COUNTIF and COUNTIFS that run instantly on thousands of rows.
  3. It integrates with filters, pivot tables, charts, and conditional formatting, allowing counted results to flow directly into reports and dashboards.

Not knowing how to perform criterion-based counting keeps you from automating month-end close, KPI dashboards, and data quality checks. Worse, it often forces people to do repetitive manual tallies, leading to missed deadlines and reporting errors. Mastering the techniques in this guide not only speeds up number crunching but also connects seamlessly to other Excel skills like SUMIF(S), AVERAGEIF(S), data validation, and dynamic arrays, giving you a solid foundation for any analytical workflow.

Best Excel Approach

The go-to solution for counting with a single condition is the COUNTIF function. When you need two or more conditions, use its sibling COUNTIFS. They are fast, easy to remember, and backwards-compatible to Excel 2007.

COUNTIF Syntax

=COUNTIF(range, criteria)
  • range The continuous block of cells you want to evaluate
  • criteria A text string, number, logical expression, or cell reference that defines which cells to count

COUNTIFS Syntax (multiple criteria)

=COUNTIFS(range1, criteria1, range2, criteria2, ...)

Excel evaluates each row against every pair you provide; a row is counted only when it satisfies all conditions (logical AND). Because COUNTIF(S) functions work on in-memory ranges, they calculate near-instantaneously even on tens of thousands of rows. Use them when:

  • Your dataset is stored inside the workbook (not an external model)
  • Criteria are straightforward (equals, greater than, text contains, dates within range)
  • Results must refresh whenever data changes

Reserve alternatives like PivotTables or Power Query when you need grouping by many fields, complex transformations, or millions of rows. For 90 percent of daily reporting tasks, COUNTIF(S) offers the cleanest solution with minimal setup.

Parameters and Inputs

To guarantee reliable results, pay close attention to each argument:

  • range
    – Must be a contiguous set of cells such as [B2:B1000] or [A2:D500] for COUNTIFS.
    – Avoid mixing numeric and text values unless the logic demands it.
    – Do not include headers; they will be evaluated as data.

  • criteria
    – If you compare numbers, you may enter them directly (for example 10) or as a text operator string ">10".
    – For text, wrap the phrase in quotes "Express"; COUNTIF is not case-sensitive.
    – Use wildcards * (matches any sequence) and ? (matches exactly one character) to create partial matches.
    – Cell references are allowed: COUNTIF(B2:B100, E2).

  • Data Preparation
    – Ensure dates are real Excel date serials, not text.
    – Trim extra spaces that break text matching.
    – Convert numbers stored as text so numeric comparisons work.

  • Edge Cases
    – Blank cells: COUNTIF counts blanks only when the criteria is "".
    – Error cells (#N/A, #DIV/0!): they are ignored unless the criteria explicitly looks for them.

Adhering to clean data inputs and correct criteria syntax eliminates the majority of counting errors.

Step-by-Step Examples

Example 1: Basic Scenario — Counting Closed Deals

Business question: “How many deals have a status of Closed Won?”

Sample data (in [A1:B11])

Deal IDStatus
1001Open
1002Closed Won
1003Closed Lost
1004Closed Won
1005Open
1006Closed Won
1007Closed Lost
1008Open
1009Closed Won
1010Closed Won

Steps

  1. Click in an empty summary cell, say D2.
  2. Enter the formula:
=COUNTIF(B2:B11,"Closed Won")
  1. Press Enter. Excel returns 5, indicating five deals meet the criterion.

Why it works
COUNTIF inspects each cell in [B2:B11]; whenever the content equals the text string “Closed Won”, the internal counter increments. Because COUNTIF is not case-sensitive, variations like “CLOSED WON” also match. For partial matches you could use the wildcard "*Won".

Common variations

  • Count open deals: COUNTIF(B2:B11,"Open")
  • Counting blanks (e.g., deals without status): COUNTIF(B2:B11,"")

Troubleshooting

If the result is zero despite visible “Closed Won” entries, check for trailing spaces ("Closed Won "), hidden characters, or incorrect range references.

Example 2: Real-World Application — Monthly Sales Orders over Target

Scenario
A sales operations team receives a sheet with each order’s date and value. Management wants to know, for March 2024, how many orders exceeded $2 000 so they can plan bonus payouts.

Sample data (simplified—real files usually span thousands of rows):

Order DateAmount
03-01-20241850
03-02-20242150
03-04-20242400
02-25-20242200
03-18-20242600
03-20-20241800
03-28-20243050
04-02-20241990

Data lives in [A2:B9]. Two conditions exist: date in March 2024 and amount greater than $2 000. This calls for COUNTIFS.

  1. Create helper cells for criteria to allow easy changes:
    – D\2 = first day of month: 3/1/2024
    – D\3 = first day of next month: 4/1/2024
    – D\4 = target amount: 2000

  2. In E2, enter:

=COUNTIFS(
    A2:A9,">="&$D$2,
    A2:A9,"<"&$D$3,
    B2:B9,">"&$D$4
)
  1. The result 4 tells us four orders satisfy both the month boundary and value threshold.

Business impact
Using COUNTIFS avoids manual filtering each month. The team can reference these summary cells inside bonus formulas, charts, or even PowerPoint links, ensuring the figure is always current.

Integration tips

  • Convert the data range to an Excel Table (Ctrl + T). Structured references like Table1[Order Date] make formulas resilient when new rows are added.
  • Combine with SUMIFS to obtain total revenue for the same subset without rewriting criteria.

Performance considerations
COUNTIFS processes each criterion pair in a single pass of memory, so even datasets with 100 000 rows calculate almost instantly. Ensure ranges remain the same size; mismatched dimensions cause #VALUE!.

Example 3: Advanced Technique — Dynamic Arrays and Multiple OR Conditions

Scenario
Human Resources maintains a master employee list with Department and Status (Active, Terminated, On Leave). Leadership asks: “How many employees are either in Marketing or IT with a status of Active?” The dataset spans 15 000 rows.

Traditional COUNTIFS supports only logical AND between different columns. To add an OR-type criterion within the same column, we combine two COUNTIFS or use a dynamic array with the new FILTER and COUNTA functions (Excel 365+).

Approach A—Sum of two COUNTIFS

=COUNTIFS(DeptRange,"Marketing",StatusRange,"Active")
+COUNTIFS(DeptRange,"IT",StatusRange,"Active")

Approach B—Dynamic array

  1. Define names (Formulas ▶ Name Manager)
    – DeptRange = [TableEmployees[Department]]
    – StatusRange = [TableEmployees[Status]]

  2. In a summary cell:

=COUNTA(
    FILTER(
        StatusRange,
        ( (DeptRange="Marketing") + (DeptRange="IT") ) * (StatusRange="Active")
    )
)

Explanation
Inside FILTER, the addition (DeptRange="Marketing") + (DeptRange="IT") creates a Boolean OR; results are multiplied by (StatusRange="Active") to enforce AND with status. FILTER spills only the rows meeting all conditions, and COUNTA tallies them.

Why use this technique?

  • Extends to many OR items without chaining multiple COUNTIFS.
  • Provides the underlying list, not just the count, which aids audits.
  • Dynamic arrays auto-resize with data growth.

Edge case management

  • FILTER returns #CALC! if no data matches; wrap with IFERROR(…,0) to display zero.
  • Large datasets (over 100 000 rows) may recalc slower; consider adding a data model pivot in such cases.

Tips and Best Practices

  1. Anchor criteria cells – Store critical values like threshold amounts or dates in separate input cells. Reference them with `

How to Countif Function in Excel

Why This Task Matters in Excel

In every spreadsheet you build—whether it is a sales tracker, a project dashboard, or a payroll register—it never takes long before you have to count how many entries meet a particular condition. Managers want to know how many sales reps beat quota, HR asks how many employees are eligible for overtime, and operations needs the number of orders waiting to be shipped. Counting filtered by criteria is so common that failing to master it slows down virtually every analytical workflow.

Imagine an e-commerce analyst who receives a customer order sheet every morning. To forecast shipping capacity, the analyst must quickly answer questions such as:

  • How many orders are marked “Express Shipping”?
  • How many orders were placed in March?
  • Within those, how many are valued greater than $200?

The faster the analyst can answer these, the quicker the warehouse can prioritize picking and packing. The same principle appears in finance (count invoices overdue), education (count students with test scores above 90), healthcare (count patients scheduled this week), and countless other industries.

Excel is particularly well-suited for this task because:

  1. It stores data in a tabular grid, ready for range-based functions.
  2. It provides built-in aggregation functions like COUNTIF and COUNTIFS that run instantly on thousands of rows.
  3. It integrates with filters, pivot tables, charts, and conditional formatting, allowing counted results to flow directly into reports and dashboards.

Not knowing how to perform criterion-based counting keeps you from automating month-end close, KPI dashboards, and data quality checks. Worse, it often forces people to do repetitive manual tallies, leading to missed deadlines and reporting errors. Mastering the techniques in this guide not only speeds up number crunching but also connects seamlessly to other Excel skills like SUMIF(S), AVERAGEIF(S), data validation, and dynamic arrays, giving you a solid foundation for any analytical workflow.

Best Excel Approach

The go-to solution for counting with a single condition is the COUNTIF function. When you need two or more conditions, use its sibling COUNTIFS. They are fast, easy to remember, and backwards-compatible to Excel 2007.

COUNTIF Syntax

CODE_BLOCK_0

  • range The continuous block of cells you want to evaluate
  • criteria A text string, number, logical expression, or cell reference that defines which cells to count

COUNTIFS Syntax (multiple criteria)

CODE_BLOCK_1

Excel evaluates each row against every pair you provide; a row is counted only when it satisfies all conditions (logical AND). Because COUNTIF(S) functions work on in-memory ranges, they calculate near-instantaneously even on tens of thousands of rows. Use them when:

  • Your dataset is stored inside the workbook (not an external model)
  • Criteria are straightforward (equals, greater than, text contains, dates within range)
  • Results must refresh whenever data changes

Reserve alternatives like PivotTables or Power Query when you need grouping by many fields, complex transformations, or millions of rows. For 90 percent of daily reporting tasks, COUNTIF(S) offers the cleanest solution with minimal setup.

Parameters and Inputs

To guarantee reliable results, pay close attention to each argument:

  • range
    – Must be a contiguous set of cells such as [B2:B1000] or [A2:D500] for COUNTIFS.
    – Avoid mixing numeric and text values unless the logic demands it.
    – Do not include headers; they will be evaluated as data.

  • criteria
    – If you compare numbers, you may enter them directly (for example 10) or as a text operator string ">10".
    – For text, wrap the phrase in quotes "Express"; COUNTIF is not case-sensitive.
    – Use wildcards * (matches any sequence) and ? (matches exactly one character) to create partial matches.
    – Cell references are allowed: COUNTIF(B2:B100, E2).

  • Data Preparation
    – Ensure dates are real Excel date serials, not text.
    – Trim extra spaces that break text matching.
    – Convert numbers stored as text so numeric comparisons work.

  • Edge Cases
    – Blank cells: COUNTIF counts blanks only when the criteria is "".
    – Error cells (#N/A, #DIV/0!): they are ignored unless the criteria explicitly looks for them.

Adhering to clean data inputs and correct criteria syntax eliminates the majority of counting errors.

Step-by-Step Examples

Example 1: Basic Scenario — Counting Closed Deals

Business question: “How many deals have a status of Closed Won?”

Sample data (in [A1:B11])

Deal IDStatus
1001Open
1002Closed Won
1003Closed Lost
1004Closed Won
1005Open
1006Closed Won
1007Closed Lost
1008Open
1009Closed Won
1010Closed Won

Steps

  1. Click in an empty summary cell, say D2.
  2. Enter the formula:

CODE_BLOCK_2

  1. Press Enter. Excel returns 5, indicating five deals meet the criterion.

Why it works
COUNTIF inspects each cell in [B2:B11]; whenever the content equals the text string “Closed Won”, the internal counter increments. Because COUNTIF is not case-sensitive, variations like “CLOSED WON” also match. For partial matches you could use the wildcard "*Won".

Common variations

  • Count open deals: COUNTIF(B2:B11,"Open")
  • Counting blanks (e.g., deals without status): COUNTIF(B2:B11,"")

Troubleshooting

If the result is zero despite visible “Closed Won” entries, check for trailing spaces ("Closed Won "), hidden characters, or incorrect range references.

Example 2: Real-World Application — Monthly Sales Orders over Target

Scenario
A sales operations team receives a sheet with each order’s date and value. Management wants to know, for March 2024, how many orders exceeded $2 000 so they can plan bonus payouts.

Sample data (simplified—real files usually span thousands of rows):

Order DateAmount
03-01-20241850
03-02-20242150
03-04-20242400
02-25-20242200
03-18-20242600
03-20-20241800
03-28-20243050
04-02-20241990

Data lives in [A2:B9]. Two conditions exist: date in March 2024 and amount greater than $2 000. This calls for COUNTIFS.

  1. Create helper cells for criteria to allow easy changes:
    – D\2 = first day of month: 3/1/2024
    – D\3 = first day of next month: 4/1/2024
    – D\4 = target amount: 2000

  2. In E2, enter:

CODE_BLOCK_3

  1. The result 4 tells us four orders satisfy both the month boundary and value threshold.

Business impact
Using COUNTIFS avoids manual filtering each month. The team can reference these summary cells inside bonus formulas, charts, or even PowerPoint links, ensuring the figure is always current.

Integration tips

  • Convert the data range to an Excel Table (Ctrl + T). Structured references like Table1[Order Date] make formulas resilient when new rows are added.
  • Combine with SUMIFS to obtain total revenue for the same subset without rewriting criteria.

Performance considerations
COUNTIFS processes each criterion pair in a single pass of memory, so even datasets with 100 000 rows calculate almost instantly. Ensure ranges remain the same size; mismatched dimensions cause #VALUE!.

Example 3: Advanced Technique — Dynamic Arrays and Multiple OR Conditions

Scenario
Human Resources maintains a master employee list with Department and Status (Active, Terminated, On Leave). Leadership asks: “How many employees are either in Marketing or IT with a status of Active?” The dataset spans 15 000 rows.

Traditional COUNTIFS supports only logical AND between different columns. To add an OR-type criterion within the same column, we combine two COUNTIFS or use a dynamic array with the new FILTER and COUNTA functions (Excel 365+).

Approach A—Sum of two COUNTIFS

CODE_BLOCK_4

Approach B—Dynamic array

  1. Define names (Formulas ▶ Name Manager)
    – DeptRange = [TableEmployees[Department]]
    – StatusRange = [TableEmployees[Status]]

  2. In a summary cell:

CODE_BLOCK_5

Explanation
Inside FILTER, the addition (DeptRange="Marketing") + (DeptRange="IT") creates a Boolean OR; results are multiplied by (StatusRange="Active") to enforce AND with status. FILTER spills only the rows meeting all conditions, and COUNTA tallies them.

Why use this technique?

  • Extends to many OR items without chaining multiple COUNTIFS.
  • Provides the underlying list, not just the count, which aids audits.
  • Dynamic arrays auto-resize with data growth.

Edge case management

  • FILTER returns #CALC! if no data matches; wrap with IFERROR(…,0) to display zero.
  • Large datasets (over 100 000 rows) may recalc slower; consider adding a data model pivot in such cases.

Tips and Best Practices

  1. Anchor criteria cells – Store critical values like threshold amounts or dates in separate input cells. Reference them with anchors ($D$2) so stakeholders can tweak numbers without touching formulas.
  2. Convert data to Excel Tables – Structured references (e.g., Sales[Amount]) expand automatically, preventing off-by-one errors when new rows are appended.
  3. Use wildcards wiselyCOUNTIF(A:A,"*Inc") captures “XYZ Inc” and “ABC Inc.” but not “Incubator.” Double-check matches when you rely on partial text.
  4. Standardize data types – A single number stored as text will cause numeric criteria to miss it. Use the VALUE function or Text to Columns to clean imports.
  5. Filter before counting on massive files – Apply an AutoFilter or Advanced Filter to reduce range size when spreadsheets grow above a few hundred thousand rows. It lightens memory load and recalculation time.
  6. Document your logic – Add comments or a small note indicating what each COUNTIF(S) is counting. Future maintainers—including you—will thank you.

Common Mistakes to Avoid

  1. Mismatched range sizes in COUNTIFS
    – All range arguments must be exactly the same number of rows and columns. If not, Excel returns #VALUE!. Always verify with the Name Box or Table icons.
  2. Forgetting quotes around relational operators
    ">10" is valid; >10 without quotes yields #NAME?. Remember that criteria containing an operator must be text.
  3. Including headers in ranges
    – Selecting whole columns like A:B is fine, but partially selecting starting at row 1 pulls in headers that skew counts. Start at row 2 or convert to a Table which automatically excludes header rows.
  4. Hidden spaces and non-printing characters
    – “Closed Won ” (note the trailing space) will not match \"Closed Won\". Use TRIM or CLEAN to sanitize source data, or include wildcards to account for unknown spacing.
  5. Mixing ≤ and ≥ incorrectly
    – Counting dates between two values is delicate: start date requires “greater than or equal to” while the end date should be strictly less than the first day of the following period to avoid double-counting boundary records.

Alternative Methods

When should you consider something other than COUNTIF(S)? The table below summarizes options:

MethodProsConsBest Use Case
COUNTIF(S)Simple, fast, dynamic, minimal setupAND logic only between columns, limited OR workaroundDay-to-day KPI tallies under 100 000 rows
PivotTableDrag-and-drop, multiple levels, quick subtotalsManual refresh unless set to auto, less transparent formulasPeriodic summary reports distributed to managers
SUMPRODUCTHandles complex Boolean algebra, array logicHarder to read, slower on very large datasetsAdvanced multi-criteria counts with OR and NOT conditions
FILTER + COUNTA (365)Returns actual records and count, native OR, spillsRequires modern Excel, can be slower on big filesInteractive dashboards needing both detail and summary
Power QueryImports, transforms, and aggregates millions of rowsSeparate refresh step, learning curveETL workflows or files exceeding Excel row limit

Choose the lightest tool that solves your problem. Migrating is straightforward: you can start with COUNTIFS and later replace it with a PivotTable or Power Query as data grows without breaking downstream formulas—just link your reports to named ranges or slicers rather than raw cells.

FAQ

When should I use this approach?

Use COUNTIF for single-criterion tallies such as “how many units are backordered,” and COUNTIFS when you have to apply multiple filters simultaneously, for example counting sales above $500 booked by a specific rep last quarter. If your criteria require OR logic within one column, either sum multiple COUNTIFS or move to SUMPRODUCT or FILTER.

Can this work across multiple sheets?

Yes. Reference external sheets directly in the range argument, e.g.:

=COUNTIF('Jan Data'!C2:C1000,"Delivered")

For COUNTIFS, each range can point to a different sheet as long as sizes match. However, ranges cannot span different workbooks unless they are open.

What are the limitations?

COUNTIF(S) cannot mix AND and OR conditions in the same call, cannot use regular expressions (only simple wildcards), and ignores case sensitivity. It also does not work on closed external workbooks. File size above roughly 200 000 rows may cause noticeable recalc delay.

How do I handle errors?

Wrap your formula in IFERROR to trap unexpected issues:

=IFERROR(COUNTIF(A2:A100,"#N/A"),0)

To ignore rows containing any error, combine with the FILTER function or cleanse data upstream. For criteria referencing blank cells, initialize empty input cells with NA() so they are less likely to be overlooked.

Does this work in older Excel versions?

COUNTIF has existed since Excel 2000; COUNTIFS appears in Excel 2007. All formulas shown—except FILTER—work in Excel 2007 onward. Dynamic array techniques require Microsoft 365 or Excel 2021.

What about performance with large datasets?

COUNTIFS on 100 000 rows with three criteria usually computes in a fraction of a second. Slowdowns appear with volatile functions (INDIRECT, TODAY) or when ranges point to entire columns. Limiting ranges to used rows and turning off automatic calculation until needed improves speed. For million-row tables, move aggregation to Power Pivot or Power Query.

Conclusion

Being able to count records that meet specific criteria sits at the heart of everyday analytics. From instant KPI checks to automated compliance reports, COUNTIF(S) delivers a fast, transparent, and extremely flexible solution. Mastering it not only boosts your productivity but also creates a stepping-stone toward advanced Excel skills like dynamic arrays, PivotTables, and data modeling. Practice the techniques in this guide, keep your data clean, and soon you’ll slice and dice information at the speed stakeholders demand. Happy counting!

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.