If it’s Sunny, then I’ll go out; otherwise I’ll stay home. If the Red Sox win, I’ll celebrate, if not, I won’t. These and many others are basic decisions we are faced with on a daily basis. They are so commonplace for us all that we don’t even think of the logic behind our decision making!
Excel offers us a similar function, but this time we will understand the logic. For example, if the month is May, then add up this range of cells, if not add up this other range of cells. If a particular cell is greater than $1000, then display “Good Job!”, otherwise display “Better Luck Next Time”.
The most basic explanation of the IF statement is this: IF(Something, This, That). The key is to remember that the commas are your deciders. Mentally replace the first comma with “THEN” and the second comma with “OTHERWISE”. So verbally, the logic would sound like IF(Something THEN This OTHERWISE That). Armed with this knowledge, anyone can write an IF Statement in Excel quickly and easily. (Some folks use the terminology IF, THEN, ELSE; either way it means the same thing.)
Here is a visual representation of the last example.
The formula first checks whether or not the cell has a value that is greater than $1000. If the argument is positive (in other words the answer is yes - it does have a value over $1000), it will display the words “Good Job!”, if the argument is negative (in other words the answer is no - it doesn’t have a value greater than $1000), it will display “Better Luck Next Time”.
Multiple IF’s
You can also nest IF Statements. For example: If it’s Sunny, and if the Red Sox are playing, then I’ll go to the game; otherwise I’ll stay home. A formula with those arguments would look like: =IF(Sunny, IF(Red Sox Playing, Go to the Game, Stay Home),Stay Home)
As you see, the second IF Statement sits completely between the “THEN” comma and the “OTHERWISE” comma (including the closing parentheses). This means that if, and only if, the first IF statement (Is it Sunny?) results in a positive result (Yes, it's Sunny), it will look at this second IF Statement. If the result of the first IF Statement is negative (It's not Sunny), it will bypass the second IF Statement completely and go straight to "Stay Home".
Depending on your version of Excel, you may only be able to nest up to 7 IF Statements in one cell.
Tell me what you think of my explanation of the IF Statement by posting a comment below!
Keep Excelling!
Do you like this post? Comment below and / or share on Facebook or Twitter!
No comments:
Post a Comment