This post will guide you how to count the number of cells that do not contain errors within a range of cells using a formula in Excel 2013/2016 or Excel office 365. How do I count the number of cells without any errors using a simple formula in Excel.
1. Count Number of Cells that do Not Contain Errors using Formula
You can use the SUMPRODUCT function in combining with NOT and ISERROR functions to count cells in a specified range of cells that do not contain errors
The below is a generic formula to count the number of cells that do not contain errors:
Supposing that you wish to count the number of cells in range B1:B6 that do not contain errors, and you can use the following formula:
LET’S SEE THAT HOW THIS FORMULA WORKS:
The NOT and ISERROR functions can be used to identify the cells that do not contain an error. And it returns an array result with TRUE or FALSE values. The TRUE values indicate cells without errors, and FALSE values indicate cells with error values.
The array result is like this:
Then you still need to convert the above array result to their numeric values, 1 and 0, so that the SUMPRODUCT function can calculate the sum of products of corresponding numbers. And you can do this with a double negative operator. And the final array result is like this:
The SUMPRODUCT function sums the items in the above array and return the final result.
You can also use the SUM function to count the cell that do not contain errors in range B1:B6. And the generic formula is similar with the above formula. It need to be entered as an array formula through pressing
CTRL +SHIFT + Enter to convert it as array formula. The formula looks like this:
2. Count Cells that do not Contain Errors using User Defined Function with VBA Code
If you want to count the number of cells that do not contain errors in a range, you can write a user defined function with VBA code. Here are the steps to create and run the function:
Step1: Press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
Step2: Click Insert > Module, and paste the following code in the Module Window.
Function CountNonErrors_ExcelHow(rng As Range) As Long Dim cell As Range Dim count As Long count = 0 For Each cell In rng If Not IsError(cell.Value) Then count = count + 1 End If Next cell CountNonErrors_ExcelHow = count End Function
Step3: Save and close the window.
Step4: In a blank cell, enter the formula:
Where B1:B6 is the range you want to count.
Step5: Press Enter to get the result. This function will return the number of cells that do not contain errors in the specified range.
3. Video: Count Cells that do not Contain Errors in Excel
This video will show you how to count cells that do not contain errors in Excel using a simple formula and a VBA code.
4. Related Functions
- Excel SUMPRODUCT function
The Excel SUMPRODUCT function multiplies corresponding components in the given one or more arrays or ranges, and returns the sum of those products. The syntax of the SUMPRODUCT function is as below:= SUMPRODUCT (array1,[array2],…)…
- Excel ISERROR function
The Excel ISERROR function used to check for any error type that excel generates and it returns TRUE for any error type, and the ISERR function also can be checked for error values except #N/A error, it returns TRUE while the error is #N/A. The syntax of the ISERROR function is as below:= ISERROR (value)….
- Excel SUM function
The Excel SUM function will adds all numbers in a range of cells and returns the sum of these values. You can add individual values, cell references or ranges in excel.The syntax of the SUM function is as below:= SUM(number1,[number2],…)…
- Excel NOT function
The Excel NOT function returns the opposite of a given logical or Boolean value. For example, if you supplied with the value TRUE, the NOT function will return FALSE; If you supplied with the value FALSE, and the NOT function will TRUE. The syntax of the NOT function is as below:=NOT(logical)…