Count if it is not blank excel

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

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?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

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. 

Countif Not Blank in Excel

Excel COUNTIF Not Blank (Table of Contents)

  • COUNTIF Not Blank in Excel
  • The syntax for COUNTIF Not Blank in Excel
  • How to use COUNTIF Not Blank in Excel?

COUNTIF Not Blank in Excel

COUNTIF Not Blank function is used for counting of any defined number/text range of any column without considering any blank cell. This becomes possible only by using the COUNTIF function, which follows the defined criteria to get the desired output.

Syntax for COUNTIF Not Blank in Excel 

Syntax

COUNTIF(Range, Criteria)

Syntax for COUNTIF Function includes 2 parameters which are as follows:

Range = The range we need to select from where we will get the count.

Criteria = Criteria should be any exact word or number we need to count.

The return value of COUNTIF in Excel is a positive number. The value can be zero or non-zero.

How to Use?

Using Excel Countif Not Blank is very easy. Here we will see How to use COUNTIF Function to find how many cells are not blank in the Excel sheet. Let’s understand the working of the COUNTIF Function in Excel through some examples below.

You can download this Excel COUNTIF Not Blank Template here – Excel COUNTIF Not Blank Template

COUNTIF Not Blank in Excel – Example #1

We have small data of some random text and numbers in a column. And this column has a blank cell as well. It becomes very difficult to count the cell without blank cells for a large amount of data. So, we will apply the COUNTIF function with the combination of criteria that allow the formula to neglect the blank and give a total number of cells with some value.

Countif Not Blank Example 1-1

As we can see in the above screenshot, column A has data from A2 to A7, and it has a blank cell in between at A6. Now to count the total cells but not blank, use COUNTIF. For that, go to any cell where you want to see the output and click on fx (a tab to insert functions in excel), as shown below.

Countif Not Blank Example 1-2

This fx tab is available just below the Menu bar. Once we click on it, we will get an Insert Function box, which has all the built-in functions provided by Microsoft in a cell. Please search for the COUNTIF function by scrolling it up and down and then clicking Ok, as shown in the below screenshot.

Countif Not Blank Example 1-3

As we can see in the above Insert Function box, there is a tab named Or Select a category, which has all the categories for defined functions in it. From here, we can navigate to select All options, as shown in the above screenshot, or we can select Statistical category, where we will find the COUNTIF function, as shown in the below screenshot. And then click on Ok.

Statistical Category

Once we click on Ok, another box will appear for Function Arguments, where we will need to define the Range and Criteria. Here, we have selected the range from A2 to A7 and Criteria as “<>” &,” which means cells containing values greater and lesser than any blank should be counted. And click on Ok.

Functions Arguments

The criteria can be anything, but for a non-blank cell, we need to select a cell with any value greater or lesser than blank. For that, we used “<>” &””

If the criteria we have defined are correct, then the Function Arguments box will show the box’s output as shown above on the bottom left side of the box. It shows the result of our defined range and criteria as 6.

Also, in the below screenshot, we got a count of cells that are not blank as 6. As cell A6 is blank, so COUNTIF has neglected that blank cell and gave the output of the remaining cell count, which has some value (number or text).

Countif Not Blank Example 1-6

COUNTIF Not Blank in Excel – Example #2

There is another method of using COUNTIF, not blank, which counts all selected cells but not blank by directly editing the cell. For this, go to the edit mode of any cell and press the equal “=” sign, enabling all the inbuilt functions of excel. There type COUNTIF and select it, as shown in the below screenshot.

Pressing “=” (Equal sign) in any cell enables all the functions available in Excel. And even if we type selective words (Let’s say “Count”), as shown in the screenshot below, it will give all the possible functions available. From there also, we can select the function as per our requirement.

Countif Not Blank Example 2-1

Countif Criteria

As you can see in the above screenshot, the COUNTIF function has a range and criteria to be assigned, which was also there in the previous example. So we will assign the same range as A2 to A7 and criteria as “<>” &””, as shown below.

Countif Not Blank Example 2-2

And press Enter key. We will get the count of cells with value, which is “6”, but we selected 7 cells, including cell A6, which is blank. Here also, COUNTIF functions count the total cells that are not blank.

But if we put incorrect criteria, we may get an error message, which will explain the problem, as shown in the screenshot below. Here, we have removed “” (Inverted Commas) from the Criteria and got the error for testing.

Countif Not Blank Example 2-3

If we do not know how to resolve the error, we can click on the Help button, shown in the below screenshot, which will directly take us to the Microsoft Excel Help window, guiding us to make function arguments right.

Formula Error

Note:

  •  “”(Inverted Comma) in the excel function is used when any text or blank cell needs to be captured. Here <> is the text and “” together are used to capture the cell with any value but is not blank.
  • Using “&” in a formula, we can add more criteria per our requirement.

Pros of Excel COUNTIF Not Blank in Excel

  • For large sets of data, where applying a filter takes so much time, they’re using Excel Countif Not Blank feature is useful and time-saving for counting cells not blank.
  • It gives an instant and exact result.
  • The COUNTIF formula is fully automatic; it is easy and instant to use.
  • It is very helpful in accounting work.

Things to Remember

  • Always check the data if it is migrated output of a different source. There are some chances that the data may contain blank cells with hidden values. In that case, filter the blank cell and delete the cell values to avoid incorrect output.
  • Always unhide the sheet or column to get the exact result.

Recommended Articles

This has been a guide to COUNTIF Not Blank in Excel. Here we discuss how to use COUNTIF Function to count Not Blank cells in excel, along with practical illustrations and a downloadable excel template. You can also go through our other suggested articles –

  1. COUNTIF Excel Function
  2. COUNTIF with Multiple Criteria
  3. COUNTIFS in Excel
  4. COUNTIF Examples in Excel

This is going to be a super simple post, here our aim is to find the number of cells that contain data, cells that are blank or empty should be excluded. The task is quite simple but the question becomes ‘how to do it?’. You know you want Excel to count a certain type of cells for you but if you find yourself wondering what to put in your sheets to get that count, you’re about to find out.

This tutorial will walk you through the usage of functions to count non-blank cells and at the end, we will also see a few functions to selectively count only the blank cells. So, without further ado, let’s jump right in.

Count If Cell Is Not Blank

Counting Cells That Are Not Blank

Here we are going to talk about three Excel functions that can help us to count non-blank cells from a range.

Using COUNTIF Function

The COUNTIF function counts the number of cells within a range that meet the given criteria. COUNTIF asks for the range from which it needs to count and the criteria according to which it needs to count. To count all the non-blank cells with COUNTIF we can make use of the following formula:

=COUNTIF(range,"<>")

Let’s try to understand this with an example. So, we have a dataset as shown below:

CountIf-Non-Blank-Sample-Dataset-01

From this list of product discounts, we will aim to find how many products are discounted. In Excel’s terminology, this means – we are finding out how many non-blank cells there are in column D (the non-blank cells represent the discounts on products and the blank cells represent products with no discount).

We can easily accomplish this using the following COUNTIF formula:

=COUNTIF(D3:D14,"<>")

And our final result looks something like this.

CountIf-Non-Blank-Cells-COUNTIF-Function-02

Here, the formula has been fed with the range of column D (D3:D14). The criteria for searching column D is «<>» which is the indicator for non-blank cells («» for blank cells).

The COUNTIF function has counted 8 non-blank cells as the result. This tells us that in our dataset, there are 8 products on discount.

The COUNTIF function can be used for only one condition. For multiple conditions (e.g., non-blank cells and discount more than 20%), we can use the COUNTIFS function.

The next function we will use to count if not blank cells are present in a range is the COUNTA function.

Using COUNTA Function

By its nature, the COUNTA function counts the cells in a range that are not empty. It is a single argument function (in its simplest form) requiring just the range from which to count non-blank cells.

We will use it in our last example and simply add our range D3:D14 to the COUNTA function in this way:

=COUNTA(D3:D14)

We have the same results as the COUNTIF function i.e., 8 non-blank cells, with fewer arguments.

CountIf-Non-Blank-Cells-COUNTA-Function-03

For the sole purpose of counting non-blank cells, the COUNTA function offers an easy, straightforward solution.

However, the COUNTA and COUNTIF functions will also count cells with space characters and formulas that return an empty string. This means that the functions will count cells that look blank but are not essentially blank.

Why is that a problem?

Technically, a space character or a formula that returns an empty string is very different from a blank cell. Although they look similar but technically they are two different things.

But since our purpose here is to count non-blank cells, so we might want the cells that appear blank to be counted as blank cells (technically, even though they are not blank). To accomplish this instead of using the COUNTIF or COUNTA functions it is better to use a SUMPRODUCT function. And this is what we are going to see in the next section.

Tip: If you are adamant about using the COUNTIF or COUNTA function for counting non-blank cells, another way around it would be to filter the data and get rid of the cells with hidden values. This will refine the results without the inclusion of faux blank cells. For now, we will move onto the SUMPRODUCT function.

Using SUMPRODUCT Function

The SUMPRODUCT returns the sum of the products of the supplied ranges or arrays. To count non-blank cells using SUMPRODUCT function we can use the below formula:

=SUMPRODUCT(--(C2:C13<>""))

Let’s try to understand the formula first and then we can compare it with the COUNTIF and COUNTA functions.

In the above formula, first of all, we are checking if the values in the range C2:C13 are equal to an empty string (nothing). This returns an array of boolean values like this –

=SUMPRODUCT(--({TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE}))

Now, since the SUMPRODUCT function cannot sum boolean values we are converting them to 0’s and 1’s by using the double-negatives. So, the formula gets further simplified to something like this –

=SUMPRODUCT({1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1})

The SUMPRODUCT  function adds all these 1’s and 0’s and returns the final result.

An important thing worth noting here is that the above formula does not treat space character as an empty string (nothing) so it will still be counted as a non-blank cell. To count them as blanks we can make use of the TRIM function and the final formula would look like this –

=SUMPRODUCT(--(TRIM(C2:C13)<>""))

Pro Tip: Instead of using the double negatives to convert boolean values to 1’s and 0’s we can also either add 0 to them or multiply them by 1 and our final result would still be the same.

Now, Let’s have the COUNTIF, COUNTA, and SUMPRODUCT functions side by side and analyze them:

Comparison-Of-COUNTIF-COUNTA-SUMPRODUCT-For-Non-Blank-Cells-4

What we can see from the serial numbering, is that there are 12 rows in our dataset. C5 is a blank cell that is correctly interpreted as blank cells by COUNTIF and COUNTA. It appears that there are 2 more blank cells (C8 containing a space character and C10 containing a formula that returns an empty string i.e., =»») in the range which means that there are 9 non-blank cells.

While the COUNTIF and COUNTA functions have treated C5 as a blank cell but they treat the other two C8 and C10 as non-blank cells and thus return 11 as the count.

On the other hand, the SUMPRODUCT based formula correctly identifies all such cells and hence returns 9 as the count of non-blank cells.

Recommended Reading: Counting Unique Values In Excel

Counting Blank Cells

Now is the turn for counting blank cells. We have ahead 2 very simple ways of counting empty cells with help of the COUNTBLANK and the COUNTIF function.

Using COUNTBLANK Function

The COUNTBLANK function, pretty self-explanatory, counts the number of empty/blank cells in a specified range. We will use the function plainly to get our results:

=COUNTBLANK(D3:D14)

COUNTBLANK-FUNCTION-Count-Blank-Cells

We have inserted the range D3:D14 in the formula to see how many blank cells there are in column D which will tell us the number of products with no discount. The outcome of the COUNTBLANK function is «4» blank cells.

Using COUNTIF Function

As explained above, the COUNTIF function can be used for counting both, blank and non-blank cells. Now we will see how to use COUNTIF for counting blank cells.

To count blank cells the COUNTIF function can be used as:

=COUNTIF(D3:D14,"")

COUNTIF-Function-To-Count-Blank-Cells

In the formula, which is made up of the range and criteria, we have swapped the criteria for counting non-blank cells (i.e., «<>») with the criteria for counting blank cells (i.e., «»). With the range specified as D3:D14, the COUNTIF function returns «4» blank cells as the result, indicating 4 undiscounted products.

At the end of this tutorial, we hope you won’t feel blank when trying to count if not blank and blank cells. We’re following up with more how-to’s as you read!

Понравилась статья? Поделить с друзьями:
  • Count if cell color in excel
  • Count if and sum if in excel
  • Count function with if excel
  • Count from a range in excel
  • Count frequency of words in word