Excel Formula for Counting Cells with Numbers: A Guide
In this article
To count cells that contain numbers in Excel, use the =COUNT() function. This formula ignores text, blank cells, and logical values, returning only the total number of cells within a specified range that contain numerical data. For example, if your numbers are in cells A1 through A10, the formula is =COUNT(A1:A10).
What You'll Need
- A computer with Microsoft Excel installed (works across all versions, including Excel 365, 2021, 2019, and older).
- A dataset containing a mix of numbers, text, or empty cells that you wish to analyze.
- Basic familiarity with selecting cell ranges in a spreadsheet.
Step-by-Step
- Identify Your Data Range: Locate the column or row where your numbers are stored. For this guide, let's assume your data is in column A, from cell A1 down to A20.
- Select the Result Cell: Click on the empty cell where you want the final count to appear. This is typically located below your data set or in a separate summary table.
- Start the Formula: Type the equals sign (
=) into the cell. In Excel, every formula must begin with an equals sign to tell the software that you are performing a calculation rather than entering text. - Enter the Function Name: Type
COUNTfollowed by an open parenthesis. Your cell should now look like this:=COUNT(. - Define the Range: You can define the range in two ways:
- Manual Entry: Type the range directly, such as
A1:A20. - Mouse Selection: While the parenthesis is open, click on cell A1 and drag your mouse down to cell A20. Excel will automatically populate the range for you.
- Manual Entry: Type the range directly, such as
- Close the Formula: Type the closing parenthesis
)and press the Enter key on your keyboard. - Verify the Result: The cell will now display a whole number representing how many cells in that range contain numeric values. If you have 20 cells but only 15 contain numbers (and 5 contain text or are blank), the result will be 15.
Common Mistakes
One of the most frequent errors is confusing COUNT with COUNTA. The COUNT function specifically looks for numbers. If you use COUNT on a list of names or product IDs that contain letters, the result will be 0. If you need to count any cell that is not empty (regardless of whether it contains text or numbers), you must use =COUNTA() instead.
Another common mistake is including the header row in your range. While COUNT ignores text, including a header like "Price" or "Quantity" in your range doesn't break the formula, but it can lead to confusion when you are auditing your formulas later. It is best practice to select only the data cells.
Users also frequently encounter issues with "numbers stored as text." Sometimes, data imported from external software or CSV files looks like a number but is formatted as text. Excel treats these as text strings, and the COUNT function will ignore them. You can spot these by a small green triangle in the top-left corner of the cell.
Tips
Counting Non-Contiguous Ranges: You aren't limited to a single block of cells. If you want to count numbers in column A and column C, but ignore column B, you can separate the ranges with commas: =COUNT(A1:A20, C1:C20). You can add as many individual ranges or cells as needed within the parentheses.
Using Named Ranges: For larger spreadsheets, instead of typing A1:A5000, you can highlight that range, right-click, and select "Define Name." Name it something like "SalesData." Your formula then becomes =COUNT(SalesData), which is much easier to read and maintain.
Dynamic Counting with Tables: If you convert your data range into an official Excel Table (by pressing Ctrl + T), you can use structured references. Instead of a cell range, the formula will look like =COUNT(Table1[Amount]). The benefit here is that as you add new rows to the table, the COUNT formula updates automatically without you having to change the range manually.
Combining with Other Functions: If you need to count numbers that meet a specific criterion (for example, only numbers greater than 100), the COUNT function cannot do this alone. You should use COUNTIF. The syntax would be =COUNTIF(A1:A20, ">100").
Troubleshooting
The result is 0, but I see numbers: This is almost always a formatting issue. Your numbers are likely stored as text. To fix this, select the range of cells, click the warning icon (yellow diamond) that appears next to the selection, and select "Convert to Number." Once converted, the COUNT formula will update immediately.
The formula is showing as text: If you see =COUNT(A1:A20) written in the cell instead of a number, the cell itself is formatted as "Text." Go to the Home tab, look at the Number format dropdown, and change it to "General." After changing the format, you must double-click the cell and press Enter to trigger the calculation.
The count is higher than expected: Check for hidden rows or filtered data. The COUNT function counts every cell in the range, even those that are hidden by a filter. If you only want to count the visible numbers after applying a filter, you cannot use COUNT. Instead, use the SUBTOTAL function: =SUBTOTAL(102, A1:A20). The code "102" tells Excel to perform a count of numbers while ignoring hidden rows.
#NAME? Error: This error occurs if the function name is misspelled. Ensure you have typed COUNT and not CONT or COUNTING. Excel functions must be spelled exactly as defined in the software.
Frequently Asked Questions
Does COUNT include dates?
Yes. In Excel, dates are actually stored as sequential serial numbers. Therefore, the COUNT function treats dates as numbers and will include them in the total.
Does COUNT include cells with formulas that result in a number?
Yes. As long as the final result of the formula in that cell is a number, COUNT will include it. If the formula results in an error (like #VALUE!) or text, it will be ignored.
Will blank cells be counted?
No. The COUNT function completely ignores empty cells. If you need to count blank cells specifically, you should use the COUNTBLANK function.
Can I count numbers across different worksheets?
Yes. You can reference other sheets by clicking the sheet tab while entering the formula. The syntax will look like =COUNT(Sheet2!A1:A20).
Does it count decimals and percentages?
Yes. Decimals, percentages, and currency values are all considered numerical data in Excel and are counted by the COUNT function.