offers Excel lesson videos made simple!

Sign up or log in to Magoosh Excel.

How to Use the If Function in Excel

Most beginner Excel users know how to build simple formulas. Want cells A1 and B1 multiplied together? Just enter “=A1*B1” in a new cell. But what do you do when you want a certain result only when a specific condition is met? This is where the IF function can help.

For example, take a look at the spreadsheet below. In column A is a list of test scores from a recent 100 point exam. Let’s say you want to put the word “Pass” in column B, but only if the test score is 60 points or higher.

Excel IF Function (Step 1)

Excel’s IF Function

This can be accomplished by using the IF function in Excel. The IF function looks something like this:

IF(logical_test, [value_if_true], [value_if_false])

The first parameter, logical_test, is what you are testing for. In our example, we want to test if the exam score is greater than or equal to 60 points.

The second parameter, value_if_true, is what we want to display in the cell if our logical test is true.

The third parameter, value_if_false, is what we want to display in the cell if our logical test is false.

Check out our Excel Lesson Videos for even more great Excel tips.

Pass or Fail?

Let’s see how we can apply this to our spreadsheet. In cell B2, we’ll enter the following formula:

=IF(A2>=60,”Pass”,”Fail”)

Excel IF Function (Step 2)

A few things we need to point out here. Notice we used “>=” for our logical test. That’s because 60 is still a passing grade so we need to test for greater than or equal to 60.

For the second and third parameters, the words “Pass” and “Fail” need to be in quotation marks because they are literal string values. You could also replace these with cell references (which would not need to be in quotation marks) but we’ll keep it simple for now.

We’ll repeat this same formula in cells B3 through B11, being careful to update our column A references to A3 through A11 respectively. Alternatively, you could use the drag handle in the lower right corner of cell B2 to drag and copy the formula down to cell B11. Using this method, Excel will automatically update the references to the cells in column A for us.

You could also copy cell B2 and paste it in cells B3 through B11. Again, Excel will automatically update the references to the cells in column A for us.

No matter which method you choose, our spreadsheet should look like this once all of our formulas are in place:

Excel IF Function (Step 3)

Using a static cell reference for the passing score

We can make our spreadsheet easier to maintain if we take the literal value “60” out of our IF function and replace it with a static cell reference. We’ll start by creating a label and static value in cells D1 and D2 which you can see in our updated spreadsheet below.

Excel IF Function (Step 4)

Now let’s return to cell B2 and update our formula to the following:

=IF(A2>=$D$2,”Pass”,”Fail”)

Excel IF Function (Step 5)

Notice we changed the “60” in the logical test to “$D$2”. The dollar signs assure that our cell reference will stay at D2 when we copy and paste the formula in B2 to cells B3 through B11.

Once we update all of our formulas, the spreadsheet will not look any different. That wasn’t the point. The point was to make it easier to maintain.

For instance, if the school changes its policy to where a student must receive a 65 or higher to pass, rather than updating each formula in cells B2 through B11, we simply need to change the value in cell D2 from 60 to 65. Because our IF formulas are all referencing cell D2, the spreadsheet will instantly update all the Pass/Fail values in column B.

Note that the score of 62 in cell A6 changes the value in cell B6 from “Pass” to “Fail” when we update cell D2 to “65”.

Excel IF Function (Step 6)

Now that you know how to use Excel’s IF function, start thinking of where you could use it in your own spreadsheets.

Comments are closed.


Magoosh blog comment policy: To create the best experience for our readers, we will only approve comments that are relevant to the article, general enough to be helpful to other students, concise, and well-written! 😄 Due to the high volume of comments across all of our blogs, we cannot promise that all comments will receive responses from our instructors.

We highly encourage students to help each other out and respond to other students' comments if you can!

If you are a Premium Magoosh student and would like more personalized service from our instructors, you can use the Help tab on the Magoosh dashboard. Thanks!