Contact

COUNTIF Function in Microsoft Excel: Formula, Examples & Troubleshooting

Statistical Intermediate Microsoft Excel

Learn the COUNTIF formula in Microsoft Excel: count records matching one criterion, with reproducible examples, expected answers and compatibility cautions.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: Use COUNTIF to count records matching one criterion. The example below supplies exact inputs and independently calculated expected results, so you can check your formula before replacing the demonstration values with real workbook data.

Verification: The function is covered by a vendor reference or its published formula catalogue. The worked outputs here are independently reasoned, not screenshots or native test results from Microsoft Excel. Check release-specific support and argument details in the referenced vendor help.

Availability and version history

  • Introduced: Introduction version not established by the official history reviewed.
  • Availability: Official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac.
  • Checked: October 14, 2026; official COUNTIF reference. Documentation check, not a new native test; existing example-verification notes retain their scope.

Syntax and arguments

=COUNTIF(range, criterion)

range contains the cells to test; criterion is the required number, text, or comparison expression. In formula syntax, square brackets mark optional arguments; do not type square brackets into an ordinary formula unless the particular function requires array notation. The separator shown is for the example locale and might change with spreadsheet settings.

When to use it: If a criterion comes from a cell, join comparison operators to that cell with &.

Prepare the example inputs

In an Excel workbook, format the amount and units cells as numbers before entering the formula. Use the Name Box to check the addressed cell range if the displayed value differs.

For the formulas that reference cells, enter this small dataset into A1:F9 (the first row contains headings). The Amount and Units columns are numbers; the team, status, item and agent columns are text. Keep the calculation cell outside A1:F9 so it cannot overwrite an input.

Row A · Item B · Team C · Status D · Amount E · Units F · Agent
1 Item Team Status Amount Units Agent
2 Pen East Paid 120 12 Ana
3 Pad West Pending 75 5 Bo
4 Box East Paid 210 7 Ana
5 Tape North Paid 90 0 Cy
6 Folder West Paid 150 3 Bo
7 Pen East Pending 60 8 Dee
8 Pad West Paid 125 12 Ana
9 Box North Pending 80 4 Cy

Worked example: exact formula and expected output

=COUNTIF(B2:B9,"East")

Expected result: 3. East appears in rows 2, 4, and 7.

  1. Select an unused output cell (for example H2 if the practice table occupies A1:F9).
  2. Enter the formula exactly as shown, including the opening equals sign and quoted text.
  3. Compare the displayed answer to the expected result, then inspect the source cells if it differs.

For a range formula, the row numbers include data rows only unless the example explicitly refers to headers. A result that looks plausible may still be wrong if it references the wrong column.

Second example: a different input

=COUNTIF(D2:D9,">=100")

Expected result: 4. Amounts 120, 210, 150, and 125 meet the threshold.

This second check uses the same function with a different input, helping you identify whether the first result was coincidental or caused by a shifted reference.

Excel text matching is case-insensitive

Microsoft explicitly states that COUNTIF does not distinguish upper and lower case. In a separate range H2:H5, enter East, EAST, east, West:

=COUNTIF(H2:H5,"East")

The documented-and-calculated expected result is 3. If case itself is part of an identifier, this function does not enforce that rule. Use a separately verified case-sensitive construction instead of assuming exact-looking text implies case sensitivity.

The reference’s compact argument description says text is ignored, but its many text-counting examples and wildcard rules show that labels are valid matching data. The controls here use that explicit matching behavior. Neither cell color nor font color is a COUNTIF criterion.

Advanced example: set an adjustable threshold

Put numeric 150 in H7:

=COUNTIF(D2:D9,">="&H7)

Expected result: 2, for 210 and 150. Changing H7 to 100 gives 4. The operator is quoted; the reference is concatenated outside the quotes. Typing the address into a quoted string would test literal text instead of its current numeric value.

A criterion such as “>=100” tests the underlying values. An amount displayed with no decimal places may still contain a fractional value, so the appearance of a boundary value is not enough to diagnose an unexpected count.

Advanced example: compare whole labels, patterns and literal wildcards

Enter A, AB, A?, ABC* in K2:K5:

=COUNTIF(K2:K5,"A*")
=COUNTIF(K2:K5,"A?")
=COUNTIF(K2:K5,"A~*")
=COUNTIF(K2:K5,"A~?")

Expected results are 4, 3, 1 and 1. The asterisk matches a sequence, the question mark matches one character, and the tilde makes the following wildcard literal.

For the original Item column, =COUNTIF(A2:A9,"P*") has expected result 4, covering two Pens and two Pads. This is not a count of distinct product names; repeated records are counted separately.

Advanced example: count an interval with a correct subtraction

=COUNTIF(D2:D9,">=100")-COUNTIF(D2:D9,">=150")

Expected result: 2, for 120 and 125. The subtraction removes all values at or above 150 from the set at or above 100, producing the half-open interval 100≤x<150.

The equivalent COUNTIFS form is =COUNTIFS(D2:D9,">=100",D2:D9,"<150"). A subtraction between unrelated counts is not automatically an intersection. One official sample’s stated interval description does not agree with its subtraction formula; the explicit set relationship above avoids that ambiguity.

Advanced example: distinguish OR from double counting

East has three records and Paid has five, with two records shared by both conditions. The inclusive-OR count is:

=COUNTIF(B2:B9,"East")+COUNTIF(C2:C9,"Paid")-COUNTIFS(B2:B9,"East",C2:C9,"Paid")

Expected result: 6, not eight. Adding East and West counts directly gives six because those labels are mutually exclusive within this table. Always inspect whether the selected groups overlap before adding counts.

Documented failure and cleanup cases

The official help warns about matches longer than 255 characters and documents #VALUE! in its closed-workbook-reference scenario. Such workbooks need their own verified handling; these local controls do not certify an external-link workflow.

Unexpected spaces, nonprinting characters or different quotation characters can also change a text match. Preserve the original identifier before using TRIM or CLEAN; cleanup can merge labels that were intentionally distinct. Empty cells, formula-empty strings, arbitrary errors and international character comparisons are not exhaustively certified by this finite ASCII dataset.

Important edge cases and a common mistake

Watch out: Operators inside conditions must be quoted as part of a text criterion, such as “>=100”.

If this formula needs to work in older Excel releases, consult the Microsoft version markers first; the function’s presence in a Microsoft 365 workbook does not establish Excel 2013 support.

Troubleshooting in Microsoft Excel

Microsoft documents Formulas → Evaluate Formula for Excel for Windows. If that command is unavailable in your client, put the component expressions in separate helper cells and compare their results; also check whether numeric-looking source values are stored as text. #NAME? suggests a misspelling or an unavailable new function. #VALUE! often indicates a wrong argument type; #SPILL! on array functions often means output cells are occupied.

If you get the wrong answer but no error, try these checks in order: (1) evaluate the simplified first example; (2) confirm the cell values and data types; (3) check the exact row and column boundaries; (4) verify quoted text, comparison operators and separators; (5) only then add more criteria or nested functions.

For a reproducible comparison with another spreadsheet product, use the same input values in both applications and record the installed version and locale. Different default matching behavior or handling of empty values can be a migration issue rather than a mathematical disagreement.

Moving this formula between spreadsheet programs

Excel generally uses commas in English-language help formulas; LibreOffice and Collabora Calc commonly use semicolons. An identically named function may still have different matching defaults, dynamic-array behavior or version support.

Related guides already published for this function: LibreOffice Calc | Apache OpenOffice Calc | Gnumeric | Calligra Sheets | PlanMaker 2026

If a comparison tool says Not researched here, that means we do not yet have a checked guide for that software. It does not mean the software lacks this function. See the 12-program comparison tool for a guide-coverage matrix.

Official reference and editorial verification

Evidence level: Vendor-published function catalogue / formula overview, checked for this editorial batch on October 11, 2026; example outputs verified by direct reasoning/arithmetic where applicable. No execution in Microsoft Excel was performed. Some platform-, language- and release-specific edge cases remain for native testing.

October 14, 2026 review scope

The full guide and original examples were reviewed against the direct Microsoft COUNTIF reference. Added results are independent arithmetic or narrowly documented type, shape and matching controls. Native Excel execution, exhaustive coercion and external-workbook behavior remain unperformed.