Microsoft Office Tutorials and References
In Depth Information
Testing on One Condition
Testing on One Condition
The IF function is like the Swiss Army knife of Excel functions. Really, it is
used in many situations. Often you can use it with other functions, which I
do often in this chapter. IF, structurally, is easy to understand. The function
takes three arguments:
A test that gives a true or false answer. For example, the test “is the
value in cell A5 equal to the value in cell A8” can have
only one of two possible answers, yes or no. In computer talk, that’s true
or false. This is not a calculation, mind you, but a comparison.
The data to be returned by the IF function if the test is true.
The data to be returned by the IF function if the test is false.
Sounds easy enough. Here are some examples:
Function
Comment
=IF(D10>D20,
D10, D20)
If the value in D10 is greater than the value in D20,
then the value in D10 is returned because the test
is true. If the value in D10 is not greater than — that
is, smaller or equal to — the value in D20, then the
value in D20 is returned. If the values in D10 and D20
are equal, the test returns false, and the value in D20
is returned.
=IF(D10>D20,
“Good news!”,
“Bad news!”)
If the value in D10 is greater than the value in D20,
then the text “Good News!” is returned. Otherwise
“Bad News!” is returned.
=IF(D10>D20, “”,
“Bad news!”)
If the value in D10 is greater than the value in D20,
then nothing is returned. Otherwise “Bad News!” is
returned. Note that the second argument is a pair of
empty quotes.
=IF(D10>D20,
“Good news!”, “”)
If the value in D10 is greater than the value in D20,
then “Good News!” is returned. Otherwise nothing
is returned. Note that the third argument is empty
quotes.
An important aspect to note about using IF: letting the second or third
argument return nothing. An empty string is returned, and the best way to do this
is to place two double quote marks together with nothing in the middle. The
result is that the cell containing the IF function remains blank.
IF, therefore, lets you set up two results to return — one for when the test
is true and another for when the test is false. Each result can be a number,
some text, a function or formula, or even blank.
Search JabSto ::




Custom Search