The Anatomy of an Excel IF Function
Part 2: Nesting an IF Function
(page 2 of 3)
Let's rewrite the If statement for C3. Let's first write our pseudocode so we are clear about our objective:
If B3 is blank, then leave C3 blank, otherwise IF the value in C3 is greater than or equal to 60%, then enter "Passed," otherwise enter "Failed."
Notice we have two IF statements here. The second IF statement is nested or embedded in the first. The second IF statement is what is returned if the first logical test (B3 is blank) is false.
We always begin our functions with an equal sign followed by the function name. Arguments (the information the function needs to perform its calculation) are separated by commas and enclosed in parentheses:
=IF(logical_test, value_if_true, value_if_false)
Let's use this syntax model to write our IF statement.
Our first argument will be a logical test (B3 is blank). Replace "logical_test" with B3="":
=IF(B3="", value_if_true, value_if_false)
To indicate a blank cell double quotation marks ("") are used.
If the logical test returns a true value—in other words, if B3 is blank—then we want C3 to be blank. Replace "value_if_true" with double quotation marks (""):
=IF(B3="", "", value_if_false)
If the logical test returns a false value—in other words, if B3 is not blank—then we want "Passed" entered in cell C3 if the value in B3 is 60% or better or "Failed" entered if the value is less than 60%. To accomplish this, we need to nest another IF function. Replace "value_if_false" with IF(B3>=0.6, "Passed", "Failed"):
=IF(B3="", "", IF(B3>=0.6, "Passed", "Failed"))
In our formula, the logical test is B3="" (B3 is blank), the Value if True argument is "" (a blank cell), and the Value if False argument is another IF statement: IF(B3>=0.6, "Passed", "Failed").
Notice the two closing parentheses at the end of our formula. The outermost parenthesis belongs to the first IF statement and the innermost parenthesis belongs to the nested IF statement.
page 1 | 2 | 3 | next page >>
Top of Page