 The IF function returns different values depending on whether a condition is true or false. Use it in the form =IF(Condition,True,False). For example, =IF(C2>=60,"Pass","Fail") will return "Pass" if the value in C2 is equal to or over 60 and "Fail" if the value is under 60.

Whether you’re grading exams or simply trying to make sense of a spreadsheet full of data, Microsoft Excel’s `IF` function can help. You can also use an `IF` function inside of another `IF` function to run deeper tests, too. We’ll show you how.

## What Can You Do with Excel’s IF Function?

Put simply, you can use the `IF` function to retrieve a pre-specified result based on whether the function gets a TRUE or FALSE value.

For example, if you have a score sheet, you can make it so your cells say `PASS` if someone has scored 60 or higher, or say `FAIL` if the score is 59 or lower. You can use a nested `IF` to even assign grades, like an `A` for someone with a score of 90 or higher.

## How to Write an IF Statement in Excel

To write an `IF` statement in Excel, all you have to do is type the function and specify what results to retrieve when the condition is TRUE and FALSE.

Start by launching your spreadsheet with Microsoft Excel. Then, click the cell in which you want to use the function.

In the following example, we’ll use the `IF` function to say `Pass` if the obtained score is 60 or higher and `Fail` if the score is 59 or lower.

We’ll select the D2 cell where we want to display the result. In the D2 cell, we’ll enter the following function and press Enter.

`=IF(C2>=60,"Pass","Fail")`

In the selected cell, you’ll see the result depending on the value in the C2 cell. To copy the function for all your records, from the bottom-right corner of the D2 cell, drag downwards to cover all your records. And that’s it.

Modify the `IF` function in whatever way you want and you’ll get the desired result.

## Use the Nested IF Function in Excel

A nested `IF` is an `IF` function inside of another `IF` function. You use this when you want to run another logical test after the first one.

We’ll use the following dataset to demonstrate this function: In this dataset, depending on the scores, the following results will be displayed:

• If the score is 90 or higher: A
• If the score is between 80 and 89: B
• If the score is between 70 and 79: C
• If the score is between 60 and 69: D
• If the score is between 0 and 59: F

We’ll select the D2 cell where we want to display the result, and then enter the following nested `IF` function and press Enter:

`=IF(C2>=90,"A",IF(C2>=80,"B",IF(C2>=70,"C",IF(C2>=60,"D",IF(C2>=0,"F")))))`

You’ll see the result in your selected cell. You can copy the function for all your records by dragging downwards from the D2 cell’s bottom-right corner. And you’re set.

Excel’s `IF` function is an excellent way to run various logical tests. You can use it to specify multiple conditions and display the results accordingly.

While you’re at it, check out other Excel logical functions that can be useful in your work.