The Anatomy of an Excel IF Function
Part 1: Introduction to IF Functions
(page 2 of 3)
The first argument is the logical test. A logical test is any value or expression that can be evaluated to TRUE or FALSE:
logical_test,
Arguments are separated by commas.
The second argument is the Value if True, which is the value returned if the logical test is TRUE:
value_if_true,
The third argument is the Value if False, which is the value returned if the logical test is FALSE:
value_if_false
We finish by typing the closing tag:
)
Putting it all together, we have:
=IF (logical_test, value_if_true, value_if_false)
Now we want to enter an If function into cell C3 in our worksheet. What is the logical test? Tom Thompson passed the exam. That's our test! Our logical test will return one of two values: True or False. Either Tom passed the test or he failed it.
However, we need to be more specific. How do we know that Tom passed the test? Let's say a student needs a test score of at least 60% to pass the test. Tom's test score has been enter in cell B3. Therefore, the value in cell B3 has to be greater than or equal to 0.6.
Our If function can be stated thus:
If the value in B3 is greater than or equal to 60%, then enter "Passed," otherwise enter "Failed."
This device of writing out your programming code in plain English is called pseudocode. Now that you understand the syntax of an IF function, sometimes it's useful to first write your If statement in pseudocode, and then convert it to Excel language.
Notice that all the parts of our IF function are present in our pseudocode: the function name (If), the logical test (B3 is greater than or equal to 60%), the Value if True argument (Passed), and the Value if False argument (Failed).
Solution
Open the practice file, Grades.xls, that you downloaded. Make sure that the Grades_Practice work sheet is selected.
Click cell C3 to select it. Then click in the Formula bar text box (to the right of the Insert Function button
). We will type our IF function in the formula bar text box.
page 1 | 2 | 3 | next page >>
Top of Page