One of the most powerful statements in Excel, the IF statement can be endlessly customized and nested within other formulas to accomplish almost anything you want.
The basic premise is that you can use the
IF formula to test if a condition is
FALSE. If the condition is met, or
TRUE, then you can have the formula output X, and if the condition is not met, or
FALSE, then the formula will output Y. In this case, both X and Y are rules the formula will follow based on the result of the condition specified.
If that totally lost you, don’t quit on me just yet.
As with any Excel formula, let’s start the learning process by looking at the syntax:
=IF(logical_test, [value_if_true], [value_if_false])
Each piece of syntax is separated by a
,. The first piece, the
logical_test, is the condition to be tested. For instance, let’s test to see if the number in Cell A2 is greater than 5. If the number is greater than 5, we want to return “Yes”, otherwise, return “No”.
Because the value in Cell A2 is, in fact, greater than 5 (said another way, our condition is
TRUE), our formula will return “Yes” and ignore the
[value_if_false] condition we entered of “No”.
Notice the quotations I placed around both
"No" in the formula. Those are necessary because “Yes” and “No” are both text strings, and in order for Microsoft Excel to recognize text strings inside of a formula they must be enclosed in quotations (
Try some IF statements on your own and leave a comment if you have any questions. Good luck!