Count excel cells that are not empty

In this example, the goal is to count cells in a range that are not blank (i.e. not empty). There are several ways to go about this task, depending on your needs. The article below explains different approaches.

COUNTA function

While the COUNT function only counts numbers, the COUNTA function counts both numbers and text. This means you can use COUNTA as a simple way to count cells that are not blank. In the example shown, the formula in F6 uses COUNTA like this:

=COUNTA(C5:C16) // returns 9

Since there are nine cells in the range C5:C16 that contain values, COUNTA returns 9. COUNTA is fully automatic, so there is nothing to configure.

COUNTIFS function

You can also use the COUNTIFS function to count cells that are not blank like this:

=COUNTIFS(C5:C16,"<>") // returns 9

The «<>» operator means «not equal to» in Excel, so this formula literally means count cells not equal to nothing. Because COUNTIFS can handle multiple criteria, we can easily extend this formula to count cells that are not empty in Group «A» like this:

=COUNTIFS(B5:B16,"A",C5:C16,"<>") // returns 4

The first range/criteria pair selects cells that are in Group A only. The second range/criteria pair selects cells that are not empty. The result from COUNTIFS is 4, since there are 4 cells in Group A that are not empty. You can swap the order of the range/criteria pairs with the same result.

See also: 50 examples of formula criteria.

SUMPRODUCT function

One problem with COUNTA and COUNTIFS is that they will also count empty strings («») returned by formulas as not blank, even though these cells are intended to be blank. For example, if A1 contains 21, this formula in B1 will return an empty string:

=IF(A1>30,"Overdue","")

However, COUNTA and COUNTIFS will still count B1 as not empty. If you run into this problem, you can use the SUMPRODUCT function to count cells that are not blank like this:

=SUMPRODUCT(--(C5:C16<>""))

Using SUMPRODUCT to count cells that are not blank

The expression C5:C16<>»» returns an array that contains 12 TRUE and FALSE values, and the double negative (—) converts the TRUE and FALSE values to 1s and 0s:

=SUMPRODUCT({1;1;0;1;1;0;1;1;1;0;1;1}) // returns 9

The result is 9 as before. But this formula will also ignore cells that contain formulas that return empty strings.

You can easily extend the logic used in SUMPRODUCT with other functions as needed. For example, the variant below uses the LEN function to count cells that have a length greater than zero:

=SUMPRODUCT(--(LEN(C5:C16)>0)) // returns 9

You can extend the formula to count cells that are not blank in Group A like this:

=SUMPRODUCT((LEN(C5:C16)>0)*(B5:B16="A"))

This is an example of using Boolean algebra in a formula. The double negative is no longer needed in this case because the math operation of multiplying the two arrays together automatically converts the TRUE and FALSE values to 1s and 0s:

=SUMPRODUCT({1;1;0;1;1;0;0;0;0;0;0;0}) // returns 4

The final result is 4, since there are four cells in Group A that are not blank in C5:C16.

Note: one reason the Boolean syntax above is useful is because you can drop the same logical expressions into a newer function like the FILTER function to extract cells that meet the same criteria. The SUMPRODUCT function is more versatile than RACON functions like COUNTIFS, SUMIFS, etc. and you will often see it used in formulas that solve tricky problems. You can read more about SUMPRODUCT here. 

Excel for Microsoft 365 Excel for the web Excel 2021 Excel 2019 Excel 2016 Excel 2013 Excel 2010 More…Less

Suppose you need to know if your team members have entered all their project hours in a worksheet. In other words, you need to count the cells that have data. And to complicate matters, the data may not be numeric. Some of your team members may have entered placeholder values such as «TBD». For that, use the COUNTA function.

Here’s an example:

The COUNTA function

The function counts only the cells that have data, but be aware that «data» can include spaces, which you can’t see. And yes, you could probably count the blanks in this example yourself, but imagine doing that in a big workbook. So, to use the formula:

  1. Determine the range of cells you want to count. The example above used cells B2 through D6.

  2. Select the cell where you want to see the result, the actual count. Let’s call that the result cell.

  3. In either the result cell or the formula bar, type the formula and press Enter, like so:

    =COUNTA(B2:B6)

You can also count the cells in more than one range. This example counts cells in B2 through D6, and in B9 through D13.

Using COUNTA to count 2 cell ranges

You can see Excel highlights the cells ranges, and when you press Enter, the result appears:

COUNTA function results

If you know you don’t need to count text data, just numbers and dates, use the COUNT function.

More ways to count cells that have data

  • Count characters in cells

  • Count how often a value occurs

  • Count unique values among duplicates

Need more help?

COUNTIF Not Blank Function

The COUNTIF not blank function counts non-blank cells within a range. The universal formula is “COUNTIF(range,”<>”&””)” or “COUNTIF(range,”<>”)”. This formula works with numbers, text, and date values. It also works with the logical operators like “<,” “>,” “=,” and so on.

Note: Alternatively, the COUNTA functionThe COUNTA function is an inbuilt statistical excel function that counts the number of non-blank cells (not empty) in a cell range or the cell reference. For example, cells A1 and A3 contain values but, cell A2 is empty. The formula “=COUNTA(A1,A2,A3)” returns 2.
read more
can be used to count the non-blank cells.

Table of contents
  • COUNTIF Not Blank Function
    • How to Use COUNTIF Non-Blank Function?
      • #1–Numerical Values
      • #2–Text Values
      • #3–Date Values
    • The Characteristics of COUNTIF Not Blank Function
    • Frequently Asked Questions
    • Recommended Articles

How to Use COUNTIF Non-Blank Function?

#1–Numerical Values

The steps to count non-empty cells with the help of the COUNTIF function are listed as follows:

  1. In Excel, enter the following data containing both, the data cells and the empty cells.

  2. Enter the following formula to count the data cells.

    “=COUNTIF(range,”<>”&””)”

    In the range argument, type B2:B30. Alternatively, select the range B2:B30 in the formula, as shown in the following image.

    Countif not Blank Example 1-1

  3. Press the “Enter” key. The number of non-blank cells in the range B2:B30 appear in cell C2. The output is 26, as shown in the succeeding image.

    This implies that there are 26 cells in the given range that contain a data value. This data can be a number, text, or any other value.

    Countif not Blank Example 1-2

#2–Text Values

The steps to count non-empty cells within text values are listed as follows:

  • Step 1: In Excel, enter the data as shown in the following image.

Example 2

  • Step 2: Select the range within which data needs to be checked for non-blank values. Enter the formula shown in the succeeding image.

Example 2-1

  • Step 3: Press the “Enter” key. The number of non-blank cells in the range B2:B21 appear in cell C2. The output is 15, as shown in the succeeding image.

Hence, the COUNTIF not blank formula works with text values.

Example 2-2

#3–Date Values

The steps to count non-empty cells, when the data consists of dates, are listed as follows:

  • Step 1: In Excel, enter the data as shown in the following image. Select the range whose data needs to be checked for non-blank values. Enter the following formula.

“=COUNTIF(B2:B21,”<>”&””)”

  • Step 2: Press the “Enter” key. The number of non-blank cells in the range B2:B21 appear in cell C2. The output is 14, as shown in the succeeding image.

Hence, the COUNTIF not blank formula works with data that consists of date values.

Example 3-1

The Characteristics of COUNTIF Not Blank Function

  • It is case insensitive, implying that the output remains the same irrespective of whether the formula is entered in uppercase or lowercase.
  • It works for data that consists of numbers, text, and date values.
  • It works with greater than (>) and less than (<) operators.
  • It is difficult to use the formula with long strings.
  • The criteria (condition) must be specified within a pair of inverted commas to avoid errors.

Frequently Asked Questions

How is the COUNTIF formula used to count blanks?

The universal formula for counting blanks is stated as follows:

“COUNTIF(range,””)”

This formula works with all types of data values.

Note: Alternatively, the COUNTBLANK function can be used to count blank cells.

How does the COUNTIF function count the duplicate values?

The formula for counting the duplicate value is given as follows:

“COUNTIF(range,“duplicate value”)”

The “range” represents the range within which the duplicate values are to be counted. The “duplicate value” is the exact data value that is to be counted.

For example, to count the number of times the text “fruits” appears in the range A2:A10, we use “=COUNTIF(A2:A10,“fruits”).”

  • The COUNTIF not blank function counts the non-blank cells within a given range.
  • The generic formula of the COUNTIF not blank function is stated as–“COUNTIF (range,“<>”&””).”
  • The criteria (condition) must be specified within a pair of inverted commas to avoid errors.
  • The COUNTIF functionThe COUNTIF function in Excel counts the number of cells within a range based on pre-defined criteria. It is used to count cells that include dates, numbers, or text. For example, COUNTIF(A1:A10,”Trump”) will count the number of cells within the range A1:A10 that contain the text “Trump”
    read more
    works for data that consists of numbers, text, and date values.
  • The COUNTIF formula gives the same output irrespective of whether the formula is entered in uppercase or lowercase.

Recommended Articles

This has been a guide to Excel COUNTIF not blank. Here we discuss how to use the COUNTIF function to count non-blank cells along with practical examples and a downloadable Excel template. You may learn more about Excel from the following articles –

  • Not Equal in VBA
  • COUNTIF with Multiple Criteria
  • VLOOKUP Errors
  • Use Not Equal to in Excel
  • XML in Excel

Let’s say you want to count cells that contain the number of employees in a data range, and would like to ignore any blank cells. The way to go about doing this is to use the COUNTA function.

The COUNTA function is a way to count cells containing any type of information, including error values and empty text (“”). For example, if the range contains a formula that returns an empty string, the COUNTA function counts that value. The COUNTA function does not count empty cells.

You are welcome to download the workbook to practice.

Applies To: Microsoft® Excel® 2010, 2013 and 2016.

1.To count the total number of employees in the data range A3:A19.

  • Select cell A20.
  • Type =COUNTA(A3:A19)
  • Press Enter.
  • The answer will be 15.

image-1

2. The COUNTA function returns 15 and ignores blank cells in the range A3:A19.

Instead of manually counting the cells that are not empty, you can use the COUNTA function to get an accurate result quickly and easily.


This post will guide you how to count cells that are not blank or empty in a given range cells using a formula in Excel 2013/2016.How do I count the number of cells that are not blank in a particular range with a VBA macro in Excel. You should know that excel offers several count functions to count the number of cells within a specific range, that meet the defined criteria or conditions in Excel.

If you want to count the number of cells that are not blank or non-empty in a selected range, you can use the COUNTA function or COUNTIF function.

Table of Contents

  • Method 1: Count Non-Blank or Non-empty Cells with COUNTA Function
  • Method 2: Count Non-Blank or Non-empty Cells with COUNTIF Function
  • Method 3: Count Non-Blank or Non-empty Cells with VBA Macro
    • Related Functions

Method 1: Count Non-Blank or Non-empty Cells with COUNTA Function


Assuming that you have a data list in a range A1:A6, and this range has blank cells as well. And you wish to count cell without blank cells. And you can use a formula based on the COUNTA function like this:

=COUNTA(A1:B6)

count non blank nonempty cells1

The COUNTA function can be used to count the number of cells that contain numbers, text,dates or errors. And it will ignore all empty cells automatically.

Method 2: Count Non-Blank or Non-empty Cells with COUNTIF Function


You can also use another function called COUNTIF function to achieve the same result of counting the number of cells that are not blank in Excel. For example, using the following formula:

=COUNTIF(A1:B6,”<>”)

count non blank nonempty cells2

From the above image, you would see that using the COUNTIF function to count the number of non-blank or non-empty cells in the range A1:B6 and return the same results as COUNTA function.

Method 3: Count Non-Blank or Non-empty Cells with VBA Macro


You can also create an newly VBA Macro to count cells that are not empty in a given range in Excel. just do the following steps:

Step1# open your excel workbook and then click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.

Get the position of the nth using excel vba1

Step2#  then the “Visual Basic Editor” window will appear.

Step3# click “Insert” ->”Module” to create a new module.

convert column number to letter3

Step4# paste the below VBA code into the code window. Then clicking “Save” button.

Sub CountCellNotBlank()
Dim ws As Worksheet
Set ws = Worksheets("Sheet7")
ws.Range("D3") = Application.WorksheetFunction.CountA(ws.Range("A1:B6"))
End Sub

count non blank nonempty cells5

Step5: back to the current worksheet, click on Macros button under Code group. then click Run button.

count non blank nonempty cells3

Step6: let’s see the result:

count non blank nonempty cells4

  • Excel COUNTIF function
    The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…
  • Excel COUNTA function
    The Excel COUNTA function counts the number of cells that are not empty in a range. The syntax of the COUNTA function is as below:= COUNTA(value1, [value2],…)…

Понравилась статья? Поделить с друзьями:
  • Count distinct values in excel
  • Count days from date excel
  • Count columns with values excel
  • Count characters in word file
  • Count changes in word