Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Counting Functions in Excel: How to Use COUNT, COUNTA, and COUNTIF

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Counting functions in Excel allow you to quickly determine the number of cells in a range that meet specific criteria, whether you are looking for only numbers, any non-empty cell, or cells that match a specific word or value. To count numbers, use =COUNT(range); to count all non-blank cells, use =COUNTA(range); and to count cells based on a specific condition, use =COUNTIF(range, criteria).

What You'll Need

  • A computer with Microsoft Excel installed (works across Windows, macOS, and Web versions).
  • A dataset or a spreadsheet containing the information you wish to count.
  • Basic knowledge of how to select a range of cells in a worksheet.

Step-by-Step

Depending on what you are trying to count, you will use a different function. Below are the detailed steps for the three most common counting methods. Note that menu labels and interface layouts may differ slightly depending on your version of Excel or region.

Method 1: Counting Only Numbers (The COUNT Function)

Use this when you have a mixed list of data but only want to know how many cells contain numerical values (dates and times are also counted as numbers in Excel).

  1. Click on the empty cell where you want the result to appear.
  2. Type =COUNT( into the cell.
  3. While the parenthesis is open, use your mouse to click and drag over the range of cells you want to analyze (e.g., A1 to A10). Alternatively, type the range manually, such as A1:A10.
  4. Type the closing parenthesis ) and press Enter.
  5. Excel will now display the total number of cells in that range that contain numbers, ignoring any text, errors, or empty cells.

Method 2: Counting All Non-Empty Cells (The COUNTA Function)

The "A" in COUNTA stands for "All." Use this when you need to count cells containing text, numbers, symbols, or formulas that return a value. It only ignores truly empty cells.

  1. Select the cell where you want the final count to be displayed.
  2. Type =COUNTA(.
  3. Select the range of cells you wish to count (e.g., B2 to B50).
  4. Type the closing parenthesis ) and press Enter.
  5. Excel will return the count of every cell in that range that is not blank. This is ideal for counting names in a list or IDs in a database.

Method 3: Counting Based on a Condition (The COUNTIF Function)

Use this when you only want to count cells that meet a specific requirement, such as counting how many times the word "Completed" appears in a status column.

  1. Click the cell where the result should go.
  2. Type =COUNTIF(.
  3. Select the range of cells you want to search through (e.g., C1 to C100) and then type a comma , to separate the range from the criteria.
  4. Enter your criteria. If you are looking for text, place it in double quotes (e.g., "Completed"). If you are looking for a number, you can type it directly (e.g., 10) or use a logical operator in quotes (e.g., ">50" to count numbers greater than 50).
  5. Type the closing parenthesis ) and press Enter.
  6. Excel will now show the number of cells that exactly match your specified condition.

Method 4: Counting with Multiple Conditions (The COUNTIFS Function)

If you need to count cells based on more than one rule (e.g., count rows where the region is "North" AND the sales are over 1000), use COUNTIFS.

  1. Type =COUNTIFS( into your target cell.
  2. Select the first range to check, then type a comma.
  3. Enter the first criteria (e.g., "North"), then type another comma.
  4. Select the second range to check, then type a comma.
  5. Enter the second criteria (e.g., ">1000").
  6. Close the parenthesis ) and press Enter.

Common Mistakes

Even experienced users often encounter a few recurring errors when using these functions. Being aware of these can save you significant time during data analysis.

Forgetting Quotes Around Text: One of the most frequent errors in COUNTIF and COUNTIFS is forgetting to put text criteria in double quotes. If you type =COUNTIF(A1:A10, Completed), Excel will look for a named range called "Completed" rather than the word itself, resulting in a #NAME? error. Always use "Completed".

Confusing COUNT and COUNTA: Users often use COUNT when they intend to count a list of names. Because COUNT only recognizes numbers, it will return 0 if the range contains only text. If your result is 0 but you can clearly see data in the cells, switch to COUNTA.

Hidden Spaces: Excel treats a cell containing a single space as "not empty." If you use COUNTA and the number seems too high, you may have cells that look empty but actually contain invisible spaces. Similarly, COUNTIF is sensitive to spaces; "Completed" is not the same as "Completed ".

Incorrect Range Sizes in COUNTIFS: When using COUNTIFS, every range you select must be the same size. If your first range is A1:A10 and your second range is B1:B20, Excel will return a #VALUE! error because the arrays are not aligned.

Tips

To make your counting functions more dynamic and professional, try these advanced techniques:

Use Cell References for Criteria: Instead of typing "Completed" directly into your formula, type the word "Completed" into cell E1 and change your formula to =COUNTIF(A1:A10, E1). This allows you to change the criteria by simply typing a new word in cell E1 without having to edit the formula itself.

Using Wildcards: If you want to count cells that contain a certain word but aren't an exact match, use the asterisk (*) wildcard. For example, =COUNTIF(A1:A10, "*East*") will count "North East," "South East," and "East Coast."

Counting Blanks: While COUNTA counts non-blanks, Excel provides a dedicated function for counting empty cells: =COUNTBLANK(range). This is incredibly useful for identifying missing data in a large spreadsheet.

Combining with Tables: If you convert your data range into an official Excel Table (Insert > Table), you can use structured references. Instead of A1:A100, your formula might look like =COUNTIF(Table1[Status], "Completed"). This is superior because as you add new rows to the table, the formula updates automatically to include the new data.

Troubleshooting

If your counting function is not returning the expected result, follow these steps in order:

  1. Check for Data Types: If COUNT is returning 0, check if your numbers are actually formatted as text. You can tell if there is a small green triangle in the top-left corner of the cell. Select the cells, click the warning icon, and select "Convert to Number."
  2. Trim Extra Spaces: If COUNTIF is undercounting, use the =TRIM() function in a helper column to remove leading and trailing spaces from your data, then run the count on the trimmed column.
  3. Verify Range Alignment: If you see a #VALUE! error in a COUNTIFS formula, double-check that all ranges start and end on the same row numbers (e.g., A2:A50 and B2:B50).
  4. Audit the Formula: Go to the "Formulas" tab and click "Evaluate Formula." This allows you to step through the calculation one part at a time to see exactly where the logic is failing.
  5. Check for Hidden Rows: Standard counting functions count all cells in a range, even those hidden by a filter. If you only want to count the visible cells after filtering, you cannot use COUNT; you must use the SUBTOTAL function (e.g., =SUBTOTAL(102, range) for a visible count of numbers).

Frequently Asked Questions

Can I count cells based on a date range?

Yes. Use COUNTIFS. For example, to count dates between January 1 and January 31, 2023, use =COUNTIFS(A1:A10, ">=1/1/2023", A1:A10, "<=1/31/2023").

Does COUNTA count cells with formulas that result in an empty string?

Yes. If a cell contains a formula like =IF(1=2, "Yes", ""), the result is an empty string (""), but the cell is not technically empty because it contains a formula. COUNTA will count this cell.

How do I count unique values in a list?

Excel does not have a single "COUNTUNIQUE" function in older versions. In modern Excel (Microsoft 365), you can combine functions: =COUNT(UNIQUE(range)) for numbers or =COUNTA(UNIQUE(range)) for text.

Can I count cells that are not equal to a certain value?

Yes. Use the "not equal to" operator, which is <>. For example, =COUNTIF(A1:A10, "<>Completed") will count every cell that does not say "Completed."

Why is my COUNTIF returning a result of 0 when I can see the matches?

This is usually caused by non-printing characters or trailing spaces. Ensure there are no spaces after the text in your cells or within your criteria quotes. Using a wildcard like "*Completed*" can often reveal if this is the problem.

Is there a limit to how many ranges I can use in COUNTIFS?

You can use up to 127 range/criteria pairs in a single COUNTIFS function, though using that many can significantly slow down your workbook's performance.