The simplest answer: in Google Sheets, =COUNTIF(range, criterion) counts the number of cells in a range that meet a single condition, such as =COUNTIF(A2:A100, "Paid"). It works in any web browser on sheets.google.com, and the same function exists in Microsoft Excel, though the two apps have slightly different menu paths for related features.
What COUNTIF Does and Why It Matters
COUNTIF is one of the most-used functions in Google Sheets because it turns raw data into quick answers. Instead of manually scanning a column for every occurrence of a word, a number, or a date, you write one formula that does the counting for you. It is the single-condition version of COUNTIFS, which allows multiple conditions across different ranges.
For example, if you track sales in a sheet with regions in column A and amounts in column B, you can count how many sales came from “West” with =COUNTIF(A2:A100, "West"). The result is a number, like 23. This is useful for dashboards, inventory sheets, attendance trackers, and any situation where you need a quick tally without filters or pivot tables.
COUNTIF Syntax and Arguments
The function takes exactly two arguments:
- range – the group of cells to examine. It can be a single column like
A2:A100, a row likeB1:Z1, or a rectangular block likeA2:C50. The range must be contiguous. - criterion – the condition that determines which cells to count. It can be a number, text, a cell reference, or a logical expression wrapped in quotes.
Here are the most common criterion formats:
- Exact text:
"Paid"– counts cells that equal Paid (case-insensitive, so “paid” and “PAID” both count). - Exact number:
42– counts cells that equal 42. - Greater than:
">100"– counts cells with values greater than 100. - Not equal:
"<>Pending"– counts cells that are not the text Pending. - Cell reference:
D1– counts cells that equal whatever is in D1. - Wildcards:
"A*"matches text starting with A;"?at"matches any single character followed by “at” (like Cat or Bat).
Note that when you use a comparison operator like > or <>, the entire criterion must be in quotes. If you use a cell reference with an operator, you need to concatenate with an ampersand, like "&D1 becomes ">"&D1.
How to Use COUNTIF: Step-by-Step
Using COUNTIF is straightforward:
- Open your Google Sheet in a web browser.
- Click the cell where you want the result to appear.
- Type
=COUNTIF(. - Select the range with your mouse or type it manually, then type a comma.
- Type the criterion. For text, use double quotes; for numbers, you can type the number directly.
- Close the parenthesis and press Enter.
For example, with student grades in B2:B30, to count how many are above 90, type in C1: =COUNTIF(B2:B30, ">90"). If the result is 7, that means seven students scored above 90.
On a Mac, the steps are identical because Google Sheets runs in the browser. The only difference is keyboard shortcuts: on Windows, Ctrl+C copies; on Mac, Command+C. The function itself behaves the same everywhere.
COUNTIF vs COUNTIFS vs Other Count Functions
COUNTIF is one of several counting functions in Google Sheets. Knowing which to use avoids errors:
- COUNT – counts numeric cells only.
=COUNT(A2:A100)ignores text and blanks. - COUNTA – counts all non-empty cells, including text, numbers, and errors.
- COUNTBLANK – counts empty cells in a range.
- COUNTIF – counts cells that meet one condition.
- COUNTIFS – counts cells that meet multiple conditions across multiple ranges. For example,
=COUNTIFS(A2:A100, "West", B2:B100, ">500")counts rows where region is West and amount is over 500.
If you find yourself writing multiple COUNTIF formulas and adding them together, you likely need COUNTIFS. For instance, counting both “Paid” and “Pending” in the same column can be done with =COUNTIF(A2:A100, "Paid") + COUNTIF(A2:A100, "Pending"), but a more elegant solution is =SUMPRODUCT((A2:A100="Paid")+(A2:A100="Pending")), though that is more advanced.
Common Problems and How to Fix Them
Users often run into a few recurring issues with COUNTIF:
- Case sensitivity – COUNTIF is not case-sensitive by default. If you need case-sensitive counting, you must use
=SUMPRODUCT(--EXACT(A2:A100, "Paid"))or=ARRAYFORMULA(SUM(--EXACT(A2:A100, "Paid"))). Google Sheets does not have a dedicated case-sensitive COUNTIF. - Leading or trailing spaces – If your data has extra spaces, like “Paid ” instead of “Paid”, COUNTIF will not match. Use
=TRIMto clean data first, or use wildcards like"*Paid*"to match any cell containing Paid. - Numbers stored as text – If a cell looks like a number but is left-aligned, it may be text. COUNTIF with a numeric criterion like
42will not count text “42”. Use=COUNTIF(A2:A100, "42")to match text, or convert the column to numbers. - Blank cells – To count blanks, use
=COUNTIF(A2:A100, ""). To count non-blanks, use=COUNTA(A2:A100)or=COUNTIF(A2:A100, "<>"). - Errors in range – If any cell in the range has an error like #N/A, COUNTIF may return an error or ignore it depending on criterion. To ignore errors, you might need to use FILTER or IFERROR.
Real-World Examples and Advanced Tips
Let’s walk through a few practical scenarios:
Example 1: Count orders by status. With order statuses in C2:C200, to count “Shipped” orders, use =COUNTIF(C2:C200, "Shipped"). To count all orders that are not canceled, use =COUNTIF(C2:C200, "<>Canceled").
Example 2: Count dates after a certain date. With dates in D2:D50, to count dates after January 1, 2024, use =COUNTIF(D2:D50, ">"&DATE(2024,1,1)). The DATE function ensures the date is treated as a real date.
Example 3: Count cells that contain specific text anywhere. Use wildcards: =COUNTIF(A2:A100, "*apple*") counts every cell that contains the word apple, even if it is part of a longer string like “green apple”.
Example 4: Count with a dynamic criterion from another cell. If E1 contains the status you want to count, use =COUNTIF(C2:C200, E1). If you need to concatenate an operator, like “greater than the value in E1”, use =COUNTIF(B2:B100, ">"&E1).
For performance, COUNTIF is fast even on thousands of rows. However, if you use it inside ARRAYFORMULA or on entire columns like A:A, it can slow down large sheets. Prefer limiting the range to the actual data.
COUNTIF in Excel vs Google Sheets
The function syntax is identical in Microsoft Excel for Microsoft 365: =COUNTIF(range, criterion). The main differences are:
- Case sensitivity – Excel also ignores case by default, but you can use
EXACTin an array formula similarly. - Wildcards – Both support
*and?, but Excel also supports~to escape them. Google Sheets does not use~. - Menu paths – In Excel, you can insert the function via Formulas > Insert Function. In Google Sheets, you use Insert > Function or simply type.
- Dynamic arrays – Excel 365 supports dynamic arrays, so you can get multiple results with a single formula, but COUNTIF itself works the same.
If you switch between the two, your COUNTIF formulas will generally work without changes, except for wildcard escaping.
Frequently Asked Questions
How do I count cells that contain a specific word, not exact match?
Use wildcards: =COUNTIF(A2:A100, "*word*"). This counts any cell that has “word” anywhere. If you want case-sensitive, you’ll need =SUMPRODUCT(--ISNUMBER(SEARCH("word", A2:A100))) for case-insensitive, or FIND for case-sensitive.
Can I use COUNTIF with multiple conditions?
No, COUNTIF only handles one condition. For multiple conditions, use COUNTIFS. For example, =COUNTIFS(A2:A100, "West", B2:B100, ">500") counts rows where both conditions are true.
Why is my COUNTIF returning 0 when I can see matching cells?
Check for extra spaces, text vs number formatting, or case sensitivity. Use =TRIM on the data, or use wildcards like "*"&D1&"*" to match partial text. Also ensure the criterion is in quotes if it is text or an operator.
How do I count blank or non-blank cells?
Use =COUNTIF(range, "") for blanks, and =COUNTA(range) for non-blanks. Alternatively, =COUNTIF(range, "<>") counts non-blank cells, but it will also count cells with formulas that return empty strings.
Does COUNTIF work with dates?
Yes, but you must use quotes around the date if you type it directly, like =COUNTIF(A2:A100, ">12/31/2023"). Better, use the DATE function: =COUNTIF(A2:A100, ">"&DATE(2024,1,1)) to avoid regional date issues.
Can I use COUNTIF across multiple sheets?
Yes, you can reference another sheet in the range, like =COUNTIF(Sheet2!A2:A100, "Paid"). For counting across multiple sheets with the same condition, you would need to sum multiple COUNTIFs or use a more advanced array formula.
Related
- Federal Reserve Balance Sheet Explained Simply
- Google Spreadsheet Counter: How to Count Cells
- Split String in Power Automate: 3 Ways
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Multiply Hours by Money in Excel: A Practical GuideTo calculate pay from decimal hours, put the hours in B2 and the hourly rate in C2, then…
- Shade Every Other Row in Excel: Quick, Reliable MethodsThe quickest way to shade alternating rows in Excel is to select your data, choose Home > Format…
- How to Delete a Note in Excel Without Removing DataTo delete a note in Excel for Microsoft 365 on Windows, right-click the cell containing it and choose…
- Copy and Paste Split Cells in Excel: A Practical GuideTo copy and paste split cells in Excel, first separate the contents into columns with Data > Text…
- Insert a Row Every Other Row in Excel: Easy MethodsYes. In Excel for Microsoft 365 on Windows, you can insert a blank row between existing rows by…
- Excel Ribbon Keyboard Shortcuts: A Practical GuideIn Excel for Microsoft 365 on Windows, press Alt to display KeyTips: small letters or letter combinations that…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.