## Summary

To keep a formula from calculating when certain cells are blank, you can use the IF function with a suitable logical test. In the example shown, the formula in E5 is:

``````=IF(COUNT(C5:C7)=3,SUM(C5:C7),"")
``````

Since cell C7 is empty, the formula displays no result. In the screen below, C7 contains a number and the sum is displayed:

## Generic formula

``=IF(logical_test,formula(),"")``

## Explanation

The goal is to verify the input of all required values before calculating a result. In the worksheet shown, the SUM function is used as an example only. You can use the same approach with any formula to prevent calculation until all required values are available. The logic can be adjusted in many ways to suit the situation. Below are several examples of how you can approach this problem. The best solution depends on the requirements of the project and your personal preference.

### IF + COUNT

In the example shown, we are using the IF function together with the COUNT function:

``````=IF(COUNT(C5:C7)=3,SUM(C5:C7),"")
``````

Translation: if the count of numbers in C5:C7 is 3, sum the range C5:C7. Otherwise, display nothing.

The logical test is based on the COUNT function, which counts numeric values:

``````COUNT(C5:C7)=3 // returns TRUE or FALSE
``````

This test will return FALSE until the range C5:C7 contains three numbers. This will cause the IF function to return the value_if_false, which has been supplied as an empty string (""). In Excel, an empty string will look like an empty cell. Since C7 has no value in the original worksheet, the formula displays no result. Once the range C5:C7 contains three numbers, the test will return TRUE and IF will run the SUM function, which will return the sum of C5:C7 as a final result.

There are many ways to check for blank cells, and several other options are explained below.

### IF + COUNTBLANK

The COUNTBLANK function counts empty cells in a range, so we can write a slightly more compact formula like this:

``````=IF(COUNTBLANK(C5:C7),"",SUM(C5:C7))
``````

If COUNTBLANK returns any non-zero number, the IF function will evaluate the number as TRUE, and return an empty string (""). If COUNTBLANK returns zero, IF will evaluate zero as FALSE and return the result from the SUM function.

### IF + ISBLANK

Another approach is to use the ISBLANK function. ISBLANK returns TRUE when a cell reference is empty. ISBLANK was originally designed to test one cell only, but you can use ISBLANK three times inside the OR function together like this:

``````=IF(OR(ISBLANK(C5),ISBLANK(C6),ISBLANK(C7)),"",SUM(C5:C7))
``````

OR will return TRUE if any supplied value is TRUE. In other words, the OR function will return TRUE if any of the ISBLANK functions return TRUE. Alternatively, can use a formula like this:

``````=IF(OR(ISBLANK(C5:C7),"",SUM(C5:C7))
``````

Note: this is an array formula and must be entered with control + shift + enter in Excel 2019 and older. In the current version of Excel, it will work fine as-is.

In this formula, we pass a range into ISBLANK and ISBLANK returns an array that contains 3 results. If any value in the array is TRUE, the OR function returns TRUE, causing IF to return an empty string (""). If all values in the array are FALSE (i.e. all three cells contain values), OR returns FALSE, and IF returns the result from SUM:

``````SUM(C5:C7)
``````

### IF with logical operators

Another option is to use standard logical operators like ="" and <>"" to test for empty and non-empty cells. To test for any empty cells, use a formula like this:

``````=IF(OR(C5="",C6="",C7=""),"",SUM(C5:C7))
``````

To test for non-empty cells use <>"" inside the AND function like this:

``````=IF(AND(C5<>"",C6<>"",C7<>""),SUM(C5:C7),"")
``````

In this formula, notice the SUM function has been moved to the value_if_true argument, and will only run if all 3 cells are not empty.

### IF + COUNTA

Finally, you also use the COUNTA function to test for non-empty cells like this:

``````=IF(COUNTA(C5:C7)=3,SUM(C5:C7),"")
``````

While the COUNT function only counts numeric values, the COUNTA function counts any kind of value (i.e. numbers or text). As long as the range C5:C5 contains three values (numbers or text), the result will be TRUE and the SUM function will run. This doesn't really make sense for the example shown (which requires numeric input) but it can be used in other situations.

Author

### Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.