The goal of this example is to verify input before calculating a result. The key point to understand is that any valid formula can be substituted. The SUM function is used only as an example. The logic can also be adjusted in many ways to suit the situation.
In the example shown, we are using the IF function together with the COUNT function. The criteria is an expression based on the COUNT function, which only counts numeric values:
COUNT(C5:C7)=3 // returns TRUE or FALSE
As long as the range contains three numbers (i.e. all 3 cells are not blank) the result is TRUE and IF will run the SUM function. If not, result is FALSE and IF returns an empty string (""). Since C7 has no value in the screen above, the formula shows no result.
There are many ways to check for blank cells, and several options are explained below.
The COUNTBLANK function counts empty cells in a range, so we can write a slightly more compact formula like this:
If COUNTBLANK returns any number except zero, the IF function will evaluate as TRUE, and return nothing (""). If COUNTBLANK returns zero, IF evaluates as FALSE and returns the sum.
In the example shown, input cells are all in the same contiguous range. In cases where cells are not together, you can a formula like this:
This example takes a literal approach with the ISBLANK function. Because we want to check all three cells at the same time, we need to use ISBLANK three times inside the OR function. This is the logical test inside IF:
When OR returns TRUE (at least one cell is empty), IF returns an empty string (""). When OR returns FALSE (no cells are blank), IF runs the SUM function and returns the result:
With logical operators
The ISBLANK function can be replaced with standard logical operators like this:
Alternately, we can combine the not equal to operator (<>) with AND function like this:
Notice the SUM function has been moved to the TRUE result. It will run only if C5 and C6 and C5 are not empty.
Finally, you can use the COUNTA function to check for numeric or text input:
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.