To count cells in Google Sheets, use COUNTA to count non-empty cells, COUNT for numbers, COUNTIF for cells meeting a condition, and COUNTIFS for multiple conditions. For example, =COUNTA(A2:A100) returns the number of non-empty cells in that range.
Why Counting in Google Sheets Is Different
Google Sheets is a cloud-based spreadsheet, so its counting functions work the same as Excel’s in most cases, but there are key differences. Sheets uses the same function names (COUNT, COUNTA, COUNTIF), but its implementation is optimized for online collaboration. One major difference: in Excel, COUNTA counts cells that contain any value, including errors and empty text (""); in Google Sheets, it behaves similarly, but there are subtle differences in how blank cells are handled when they contain formulas that return empty strings. Also, Google Sheets supports array formulas natively, which lets you use COUNTIF with arrays without pressing Ctrl+Shift+Enter, unlike older Excel versions.
The Core Counting Functions
Here are the primary functions you’ll use, with their exact syntax:
COUNT(value1, [value2, ...])– Counts only numeric values. Dates and times count because they are stored as numbers. Text and blanks are ignored.COUNTA(value1, [value2, ...])– Counts all non-empty cells, including text, numbers, errors, and logical values (TRUE/FALSE).COUNTBLANK(range)– Counts empty cells in a range.COUNTIF(range, criterion)– Counts cells that meet a single condition. Example:=COUNTIF(B2:B50, "Paid")counts cells equal to “Paid”.COUNTIFS(criteria_range1, criterion1, [criteria_range2, criterion2, ...])– Counts cells that meet multiple conditions across multiple ranges. Example:=COUNTIFS(A2:A50, "North", B2:B50, ">100")counts rows where region is “North” and sales exceed 100.
For example, with a list of orders in A2:A100, =COUNT(A2:A100) returns the number of orders that have numeric IDs, while =COUNTA(A2:A100) counts every row that has any data, including text labels.
How to Count Unique Values
Counting distinct items is a common need. Google Sheets has a dedicated function: COUNTUNIQUE(value1, [value2, ...]). It counts the number of unique values in a list. For example, =COUNTUNIQUE(C2:C100) returns the number of different customer names in that range. If you need to count unique values based on a condition, use COUNTUNIQUEIFS (available in newer Sheets versions) or combine UNIQUE with COUNTA: =COUNTA(UNIQUE(FILTER(C2:C100, A2:A100="East"))).
Using COUNTIF with Wildcards and Operators
COUNTIF supports wildcards and comparison operators. For text, use asterisk (*) for any sequence of characters and question mark (?) for a single character. To count cells that start with “A”, use =COUNTIF(A2:A100, "A*"). For numbers, you can use operators: =COUNTIF(B2:B100, ">=100") counts values greater than or equal to 100. To count cells that are not empty, use =COUNTIF(A2:A100, "<>"). For a literal question mark or asterisk, prefix with a tilde (~), like "~*".
Common Problems and How to Fix Them
One frequent issue is that COUNT returns 0 when you expect a count of text entries – that’s because COUNT only counts numbers. Use COUNTA instead. Another problem: COUNTIF with a date criterion. Dates must be entered as date values, not text. For example, =COUNTIF(A2:A100, DATE(2024,1,1)) counts cells equal to January 1, 2024. If you type the date as a string like “1/1/2024”, Sheets may interpret it as text and return 0. Also, when using COUNTIFS, all ranges must have the same number of rows and columns; otherwise you get a #VALUE! error. Finally, if you’re counting across multiple sheets, use a range like Sheet2!A2:A100 or combine with INDIRECT for dynamic sheet names.
Counting with Array Formulas and LAMBDA
For advanced counting, you can use array formulas. For example, to count cells that contain a specific text anywhere, use =ARRAYFORMULA(SUM(--ISNUMBER(SEARCH("apple", A2:A100)))). This counts cells that contain “apple” as a substring. In newer Sheets, you can use LAMBDA with MAP or BYROW for complex logic. For instance, =SUM(BYROW(A2:A100, LAMBDA(row, COUNTIF(row, "Yes")))) counts how many times “Yes” appears in each row and sums them. These are powerful but require an understanding of array behavior.
Comparing Google Sheets and Excel Counting
Excel and Google Sheets have nearly identical counting functions, but there are a few differences. Excel’s COUNTIF does not support wildcards for * and ? in the same way? Actually, it does, but the tilde escape is the same. A key difference: in Excel, COUNTA counts cells that contain any value, including errors and empty text; in Google Sheets, it also counts empty text (formulas returning “”), but Excel’s COUNTIF with “<>” does not count blank cells, while in Sheets it does. Also, Google Sheets has COUNTUNIQUE which Excel lacks; in Excel you’d use SUMPRODUCT or a pivot table. For dynamic arrays, Excel 365 has UNIQUE and COUNTA combined, but Sheets’ array formulas are more straightforward for some users.
Frequently Asked Questions
How do I count cells with specific text in Google Sheets?
Use COUNTIF with wildcards. For example, =COUNTIF(A2:A100, "*apple*") counts cells that contain the word “apple” anywhere. For exact match, use "apple" without wildcards. To count cells that do not contain a text, use "<>*apple*".
Why does COUNTIF return 0 for dates?
Because dates are stored as serial numbers, and if you type a date as text, it won’t match. Use DATE(2024,1,1) or a cell reference to a date. Also, ensure your range contains actual dates, not text strings that look like dates.
How do I count non-empty cells in a row?
Use COUNTA for a row range, like =COUNTA(A2:Z2). This counts all cells that are not blank, including cells with formulas that return empty strings. If you want to exclude formulas that return “”, use SUMPRODUCT with LEN: =SUMPRODUCT(--(LEN(A2:Z2)>0)).
Can I count cells based on color in Google Sheets?
No, there is no built-in function to count by cell background color. You can use Google Apps Script to write a custom function, or use a filter view and then use SUBTOTAL to count visible cells. For example, after filtering, =SUBTOTAL(103, A2:A100) counts visible non-empty cells.
What’s the difference between COUNT and COUNTA?
COUNT counts only numbers, including dates and times. COUNTA counts all non-empty cells, including text, numbers, errors, and logical values. If you have a column of IDs that are numbers, use COUNT; if you have names, use COUNTA.
How do I count unique values with multiple conditions?
Use COUNTUNIQUEIFS if available: =COUNTUNIQUEIFS(A2:A100, B2:B100, "North", C2:C100, ">100"). This counts unique values in A where B is “North” and C is greater than 100. If not available, use =COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="North", C2:C100>100))).
Related
- Google Sheets COUNTIF Case Sensitive? Exact Match
- Are Random Number Generators Truly Random?
- PLC Traffic Light Ladder Logic: How It Works
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Balance Sheet Federal Reserve FRED: How to Find & Read ItThe Federal Reserve’s balance sheet is a weekly financial statement showing the assets and liabilities of the U.S.…
- Switch Excel Workbooks: Keyboard Shortcuts and TipsIn Excel for Microsoft 365 on Windows, press Ctrl+F6 to switch to the next open workbook window, or…
- Multiple Imports on One Line? Python Style GuideYes, you can put multiple imports on one line in Python, but the official style guide (PEP 8)…
- Profit and Loss Excel Templates: How to Use ThemYes, profit and loss (P&L) Excel templates are pre-built spreadsheets that automatically calculate your revenue, costs, and net…
- How to Set Out of Office Hours in Outlook: Desktop & WebTo set out-of-office hours in Outlook, open Automatic replies, turn on automatic replies, choose the start and end…
- Clear Cache in Outlook Mail: Windows, Web, and MacTo clear cache in Outlook, first choose the version you use: in classic Outlook for Windows, clear a…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.