Excel - If Statement
An If Statement is used in Excel to do certain actions only if something is true.
For example, you might want to print out the message "We are losing money" if
total sales for the quarter are below some amount. Otherwise, you'd just want to print out
"We're making money!"
The IF function lets you do these kinds of value based decisions. This lesson
will show you a couple basic examples of how you can make use of the IF function.
Excel - IF Function
The IF function needs to have some sort of comparison to operate properly. A very
common type of comparison is greater/less than (>/<). These math symbols can be used
to form logical expressions like "A2 < 40000", which in English means "Cell A2 is less than 40000".
Now that logical expression can be either true or false and the IF function lets you
do something for each result. In this little example we will be making our IF function
print out something our boss might say.
Your excel spreadsheet should look like this:

Excel - IF Function's 3 Parts
The IF function has three parts:
- The comparison you will be doing. We are using A2 < 40000
- What to do if the If statement is true
- What to do if the If statement is false
If all that information is confusing to you, don't worry, Excel has a built in wizard
to help you make your own If functions.
- Go to the Insert menu and choose Function
- Select the Logical functions from the drop down selector

- Choose the IF function and click OK

- Put "A2<40000" as the logical expression
- Put "We are losing money?" as the true value
- Put "We are making money!" as the false value

- Press OK
Because our sales were only $30,000 the if statement should be printing out "We are losing money?"

This isn't good at all, we're going to get fired!
Make Some Accounting Adjustments
Let's make some small accounting changes and up that sales figure to $50,000
and see what the IF function prints out.

Ah that is much better, now we're making money!
Notice that when the value of
A2 was $30,000 it was less than $40,000 and our IF function was set to print out
"We are losing money?" when A2 was less than 40,0000. However, when we changed
the value of A2 to $50,000 the IF statement was now false and it printed out
"We are making money!"
Found Something Wrong in this Lesson?Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time! |