Excel IF Function
The Excel IF function is one probably one of the most powerful formulas within Excel. IF() allows you to take control based on the outcome of decisions. The basic syntax of the Excel function is:
=IF(TEST, OUTCOME A, OUTCOME B)
• “TEST” is a condition that we wish to evaluate
• “OUTCOME A” is what will happen if the condition is TRUE
• “OUTCOME B” is what will happen if the condition is FALSE
So here some quick examples of tests that could be performed:
IF(A19 > 1000, …., ….) which says check if the value in cell A19 is greater than 1000
IF(B25 <= 2000, …..,….) which says check if the value in cell B25 is less than 2000.
IF(LEN(W20)=10,……,….) which says check if the length of the value in W20 is 10.
IF(ISNUMBER(A5),…….,….) which says check if the contents of cell A5 are a number.
Now for some concrete examples of how the IF function works in practice:
1. Start a New Work book.
2. In Cell A1 enter the value 10 (and press Enter)
3. Then in Cell B1 enter the following formula:
=IF(A1 > 5,”BIGGER THAN 5″,”LESS THAN 5″)
4. The screen should look like this now:
5. If you’ve entered the formula correctly, you will see the message “Bigger than 5” appear in cell B1.
6. The formula you’ve entered in Cell B1 performs the test “A1> 5” i.e it checks if the value in Cell A1 is greater than 5. Currently the value in Cell A1 is 10 – so the condition is TRUE and the message “BIGGER THAN 5” appears
7. If we now change the value in cell A1 to 2:
Thtn the message in cell B2 is now “LESS THAN 5” as the condition is FALSE.
8. You can keep changing the value in cell A1 and the message in cell B2 will adjust accordingly.
9. Of course there are situations where the condition could give mischievous results:
• What happens if we enter the Value 5 in Cell A1 ?
• What about if we leave Cell A1 blank ?
• What about if we put some text in Cell A1 e.g the phrase DOG
Very basic stuff here, click “Next” below for some more advanced examples.