We use the IF statement in Excel to test one condition and return one value if the condition is met and another if the condition is not met.

However, we use multiple or nested IF statements when evaluating numerous conditions in a specific order to return different results.

This tutorial shows four examples of using nested IF statements in Excel and gives five alternatives to using **multiple IF statements in Excel**.

## General Syntax of Nested IF Statements (Multiple IF Statements)

The general syntax for nested IF statements is as follows:

=IF(Condition1, Value_if_true1, IF(Condition2, Value_if_true2, IF(Condition3, Value_if_true3, Value_if_false)))

This formula tests the first condition; if true, it returns the first value.

If the first condition is false, the formula moves to the second condition and returns the second value if it’s true.

Each subsequent IF function is incorporated into the **value_if_false** argument of the previous IF function.

This process continues until all conditions have been evaluated, and the formula returns the final value if none of the conditions is true.

The maximum number of nested IF statements allowed in Excel is 64.

Now, look at the following four examples of how to use nested IF statements in Excel.

## Example #1: Use Multiple IF Statements to Assign Letter Grades Based on Numeric Scores

Let’s consider the following dataset showing some students’ scores on a Math test.

We want to use nested IF statements to assign student letter grades based on their scores.

We use the following steps:

- Select cell C2 and type in the below formula:

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

- Click Enter in the cell to get the result of the formula in the cell.

- Copy the formula for the rest of the cells in the column

The assigned letter grades appear in column C.

### Explanation of the formula

=IF(B2>=90,”A”,IF(B2>=80,”B”,IF(B2>=70,”C”,IF(B2>=60,”D”,”F”))))

This formula evaluates the value in cell B2 and assigns an “A” if the value is 90 or greater, a “B” if the value is between 80 and 89, a “C” if the value is between 70 and 79, a “D” if the value is between 60 and 69, and an “F” if the value is less than 60.

Notice that it can be challenging to keep track of which parentheses go with which arguments in nested IF functions.

Therefore, as we enter the formula, Excel uses different colors for the parentheses at each level of the nested IF functions to make it easier to see which parts of the formula belong together.

Also read: How to use Excel If Statement with Multiple Conditions Range

## Example #2: Use Multiple IF Statements to Calculate Commission Based on Sales Volume

Here’s the dataset showing the sales of specific salespeople in a particular month.

We want to use multiple IF statements to calculate the tiered commission for the salespeople based on their sales volume.

We proceed as follows:

- Select cell C2 and enter the following formula:

=IF(B2>=40000, B2*0.14,IF(B2>=20000,B2*0.12,IF(B2>=10000,B2*0.105,IF(B2>0,B2*0.08,0))))

- Press the Enter key to get the result of the formula.
- Double-click or drag the Fill Handle to copy the formula down the column.

The commission for each salesperson is displayed in column D.

### Explanation of the formula

=IF(B2>=40000, B2*0.14,IF(B2>=20000,B2*0.12,IF(B2>=10000,B2*0.105,IF(B2>0,B2*0.08,0))))

This formula evaluates the value in cell B2 and then does the following:

- If the value in cell B2 is greater than or equal to 40,000, the figure is multiplied by 14% (0.14).
- If the figure in cell B2 is less than 40,000 but greater than or equal to 20,000, the value is multiplied by 12% (0.12).
- If the number in cell B2 is less than 20,000 but greater than or equal to 10,000, the figure is multiplied by 10.5% (0.105).
- If the value in cell B2 is less than 10,000 but greater than 0 (zero), the number is multiplied by 8% (0.08).
- If the value in cell B2 is 0 (zero), 0 (zero) is returned.

## Example #3: Use Multiple IF Statements to Assign Sales Performance Rating Based On Sales Target Achievement

The following is a dataset showing regional sales data of a specific technology company in a particular year.

We want to use multiple IF statements to assign a sales performance rating to each region based on their sales target achievement.

We use the following steps:

- Select cell C2 and type in the below formula:

=IF(B2>500000, "Excellent", IF(B2>400000, "Good", IF(B2>275000, "Average", "Poor")))

- Click Enter on the Formula bar.
- Drag or double-click the Fill Handle to copy the formula down the column.

The performance ratings of the regions are shown in column C.

### Explanation of the formula

=IF(B2>500000, “Excellent”, IF(B2>400000, “Good”, IF(B2>275000, “Average”, “Poor”)))

In this formula, if the sales target in cell B2 is greater than 500,000, the formula returns “Excellent.”

If it’s between 400,000 and 500,000, the formula returns “Good.”

If it’s between 275,000 and 400,000, the formula returns “Average.” And if it’s below 275,000, the formula returns “Poor.”

## Example #4: Use Multiple IF Statements in Excel to Check For Errors and Return Error Messages

Suppose we have the following dataset of students’ English test scores. Some scores are less than 0 or greater than 100, and there are no scores in some cases.

We want to use nested IF statements to check for scores in column B and display error messages in column C if there are no scores or the scores are less than 0 or greater than 100.

If the score in column B is valid, we want the formula to return an empty string in column C.

Here are the steps to follow:

- Select cell C2 and enter the following formula:

=IF(OR(B2<0,B2>100),"Score out of range",IF(ISBLANK(B2),"Invalid score",""))

- Click Enter on the Formula bar.
- Drag the Fill Handle to copy the formula down the column.

The error messages are shown in column C.

### Explanation of the formula

=IF(OR(B2<0,B2>100),”Score out of range”,IF(ISBLANK(B2),”Invalid score”,””))

This formula uses the OR function to check if the score in cell B2 is less than 0 or greater than 100, and if it is, it returns the error message “Score out of range.”

The formula also uses the ISBLANK function to check if cell B2 is blank, and if it is, it returns the error message “Invalid score.”

If there is no error, the formula returns an empty string, meaning no message is displayed in column B.

## Alternatives to Using Multiple IF Statements in Excel

Formulas using nested IF statements can become difficult to read and manage if we have more than a few conditions to test.

In addition, if we exceed the maximum allowed limit of 64 nested IF statements, we will get an error message.

Fortunately, Excel offers alternative ways to use instead of nested IF functions, especially when we need to test more than a few conditions.

We present the alternative ways in this tutorial.

### Alternative #1: Use the IFS Function

The **IFS** function tests whether one or more conditions are met and returns a value corresponding to the first TRUE condition.

Before the release of the IFS function in 2018 as part of the Excel 365 update, the only way to test multiple conditions and return a corresponding value in Excel was to use nested IF statements.

However, multiple IF statements have the downside of resulting in unwieldy formulas that are difficult to read and maintain.

In some situations, the IFS function is designed to replace the need for multiple IF functions.

The syntax of the IFS function is more straightforward and easier to read than nested IF statements, and it can handle up to 127 conditions.

Here’s an example:

Let’s consider the following dataset showing some students’ scores on a Math test.

We want to use the IFS function to assign letter grades to the students based on their scores.

We use the following steps:

- Select cell C2 and type in the below formula:

=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", B2>=60, "D", B2<60, "F")

- Click Enter on the Formula bar.
- Drag or double-click the Fill Handle to copy the formula down the column.

The student’s letter grades are shown in column C.

### Explanation of the formula

=IFS(B2>=90, “A”, B2>=80, “B”, B2>=70, “C”, B2>=60, “D”, B2<60, “F”)

This formula tests the score in cell B2 against each condition and returns the corresponding grade letter when the condition is true.

### Limitation of IFS Function

The IFS function in Excel is designed to simplify complex nested IF statements.

However, there are situations where the IFS function may not be able to replace nested IF functions completely.

One such situation is when you must calculate or operate based on a condition or set of conditions.

While the IFS function can return a value or text string based on a condition, it cannot perform calculations or operations on that value like nested IF statements.

Another situation where the IFS function may be less useful is when you need to test for a range of conditions rather than just a specific set.

This is because the IFS function requires you to specify each condition and corresponding result separately, which can become cumbersome if you have many conditions to test—in contrast, nested IF statements allow you to test for a range of conditions using logical operators like AND and OR.

The IFS function is a powerful tool for simplifying complex logical tests in Excel.

However, there may be situations where nested IF statements are more appropriate for your needs.

We recommend that you consider both options and choose the one that best fits the specific requirements of your task.

### Alternative #2: Use Nested IF Functions

We can use multiple IFS functions in a formula if we have more than one condition to test.

For example, let’s say we have the following dataset of student names and scores on a Physics test in columns A and B.

We want to assign a letter grade to each score and include a pass or fail designation based on whether the score is above or below 75.

Here are the steps to use:

- Select cell C2 and enter the following formula

=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",B2>=60,"D",B2<60,"F")&" "&IFS(B2>=75,"Pass",B2<75,"Fail")

- Click Enter on the Formula bar.
- Drag or double-click the Fill Handle to copy the formula down the column.

The letter grade and designation of the student scores are displayed in column C.

### Explanation of the formula

=IFS(B2>=90,”A”,B2>=80,”B”,B2>=70,”C”,B2>=60,”D”,B2<60,”F”)&” “&IFS(B2>=75,”Pass”,B2<75,”Fail”)

This formula uses the first IFS function to assign a letter grade based on the score in column A and the second IFS function to give a pass/fail designation based on the score in column A.

The two IFS functions are combined using the ampersand (&) operator to create a single text string that displays each score’s letter grade and pass/fail designation.

### Alternative #3: Use the Combination of CHOOSE and XMATCH Functions

The **CHOOSE** function selects a value or action from a value list based on an index number.

The **XMATCH** function locates and returns the relative position of an item in an array. We can combine these functions in a formula instead of nested IF functions.

Here’s an example:

Suppose we have the following dataset showing some students’ scores and letter grades on a Biology test.

We want to use a formula combining the CHOOSE and XMATCH functions to assign corresponding grade points in column D to each letter grade.

We use the following steps:

- Select cell D2 and type in the below formula:

=CHOOSE(XMATCH(C2,{"F","E","D","C","B","A"},0),0,1,2,3,4,5)

- Click Enter on the Formula bar.
- Drag or double-click the Fill Handle to copy the formula down the column.

The grade points for each student are displayed in column D.

### Explanation of the formula

=CHOOSE(XMATCH(C2,{“F”,”E”,”D”,”C”,”B”,”A”},0),0,1,2,3,4,5)

This formula applies the XMATCH function to find the position of the letter grade in the array {“F”,”E”,”D”,”C”,”B”,”A”}, and then uses the CHOOSE function to return the corresponding grade points.

### Alternative #4: Use the VLOOKUP Function

The **VLOOKUP** function looks for a value in the leftmost column of a table and then returns a value in the same row from a specified column.

We can use the VLOOKUP function instead of nested IF functions in Excel.

The following is an example of using the VLOOKUP function instead of nested IF functions in Excel:

Suppose we have the following dataset showing some students’ scores and letter grades on a Biology test.

We want to use the VLOOKUP function to assign grade points to each student’s letter grade in column D.

We use the steps below:

- Create a table that lists the grades and their corresponding grade points in cell range F1:G7.

- In cell D2, type the following formula:

=VLOOKUP(C2,$F$2:$G$7,2,FALSE)

**Note:** Use the dollar signs to lock down the cell range F2:G7.

- Click Enter on the Formula bar.
- Drag or double-click the Fill Handle to copy the formula down the column.

The grade points for each student appear in column D.

### Explanation of the formula

=VLOOKUP(C2,$F$2:$G$7,2,FALSE)

This formula uses the VLOOKUP function to look up the grade in cell C2 in the table in F2:G7 and return the corresponding grade point in the second column (i.e., column G).

The “FALSE” argument ensures that an exact match is required.

### Alternative #5: Use a User-Defined Function

If you need to test more than a few conditions, consider creating a **User Defined Function** in VBA that can handle many conditions.

Here’s an example of using VBA code to replace nested IF functions in Excel:

Suppose we have the following dataset showing the sales of specific salespeople in a particular month.

We want to use a User Defined Function to calculate the commission for each salesperson based on the following rates:

- If the total sales are less than $10,000, the commission rate is 8%.
- If the total sales are equal to or greater than $10,000 but less than $20,000, the commission rate is 10.5%.
- If the total sales are equal to or greater than $20,000 but less than $40,000, the commission rate is 12%.
- If the sales are equal to or greater than $40,000, the commission rate is 14%

We use the following steps:

- Open the worksheet containing the sales dataset.
- Press
**Alt + F11**to launch the**Visual Basic Editor**. - Click
**Insert**on the menu bar and choose**Module**to insert a new module.

- Enter the following VBA code.

```
'Code developed by Steve Scott from https://spreadsheetplanet.com
Function COMMISSION(Sales As Double) As Double
Const Rate1 = 0.08
Const Rate2 = 0.105
Const Rate3 = 0.12
Const Rate4 = 0.14
'Calculate sales commissions
Select Case Sales
Case 0 To 9999.99: COMMISSION = Sales * Rate1
Case 10000 To 19999.99: COMMISSION = Sales * Rate2
Case 20000 To 39999.99: COMMISSION = Sales * Rate3
Case Is >= 40000: COMMISSION = Sales * Rate4
End Select
End Function
```

- Save the function procedure and the workbook as a
**Macro-Enabled Workbook**. - Press Alt + F11 to switch to the active worksheet with the sales dataset.
- Select cell C2 and enter the following formula:

=COMMISSION(B2)

- Click Enter on the Formula bar.
- Drag or double-click the Fill Handle to copy the formula down the column.

The commission for each salesperson is displayed in column C.

This VBA function takes the sales amount as an argument and returns the corresponding commission.

The User-Defined Function is a much simpler and easier-to-read solution than using nested IF functions.

This tutorial showed four examples of using nested IF statements in Excel and gave five alternatives to using multiple IF statements in Excel. We hope you found the tutorial helpful.

**Other Excel tutorials you may find useful:**

- Excel Logical Test Using Multiple If Statements in Excel [AND/OR]
- How to Compare Two Columns in Excel (using VLOOKUP & IF)
- Using IF Function with Dates in Excel (Easy Examples)
- COUNTIF Greater Than Zero in Excel
- BETWEEN Formula in Excel (Using IF Function) – Examples
- Count Cells Less than a Value in Excel (COUNTIF Less)

Hi Scott,

Extremely useful information here. Saves a lot of time to whomever needs, like I did. Thank you!! /Richard

hello,

I have a situation where I need a formula for the bellow:

If column A2 is not null than copy value from column A2, if null than brig value from B2 , if B2 is null also than populate sysdate.

How can this be acheeved?