In Part 1 of our Excel IF function tutorial, we started to learn the nuts and bolts of the Excel IF function. As you remember, we discussed a few IF formulas for numbers, dates and text values as well as how to write an IF statement for blank and non-blank cells.

However, for powerful data analysis, you may often need to evaluate multiple conditions at a time, meaning you have to construct more sophisticated logical tests using multiple IF functions in one formula. The formula examples that follow below will show you how to do this correctly. You will also learn how to use Excel IF in array formulas and learn the basics of the IFEFFOR and IFNA functions.

In summary, there can be 2 basic types of multiple conditions - with AND and OR logic. Consequently, your IF function should embed an AND or OR function in the logical test, respectively.

- AND function. If your logical test contains the AND function, Microsoft Excel returns TRUE if
**all the conditions**are met; otherwise it returns FALSE. - OR function. In case you use the OR function in the logical test, Excel returns TRUE if
**any of the conditions**is met; FALSE otherwise.

To better illustrate the point, let's have a look at a few IF examples with multiple conditions.

Suppose, you have a table with the results of two exam scores. The first score, stored in column C, must be equal to or greater than 20. The second score, listed in column D, must be equal to or exceed 30. Only when both of the above conditions are met, a student passes the final exam.

The easiest way to make a proper formula is to write down the condition first, and then incorporate it in the logical_test argument of your IF function:

Condition: AND(B2>=20, C2>=30)

IF/AND formula:

`=IF((AND(C2>=20, D2>=30)), "Pass", "Fail")`

Easy, isn't it? The formula tells Excel to return "Pass" if a value in column C >=20 AND a value in column D >=30. Otherwise, the formula returns "Fail". The screenshot below proves that our Excel IF /AND function is correct:

In practice, a seemingly correct IF / AND formula may result in an error because of this specificity. For example, the below formula will return "Divide by Zero Error" (#DIV/0!) if cell A2 is equal to 0:

`=IF(AND(A2<>0,(1/A2)>0.5),"Good", "Bad")`

The avoid this, you should use a nested IF function:

`=IF(A2<>0, IF((1/A2)>0.5, "Good", "Bad"), "Bad")`

You use the combination of IF & OR functions in a similar way. The difference from the IF / AND formula discussed above is that Excel returns TRUE if **at least one** of the specified conditions is met.

So, if we modify the above formula in the following way:

`=IF((OR(C2>=20, D2>=30)), "Pass", "Fail")`

Column E will have the "Pass" mark if either the first score is equal to or greater than 20 **OR** the second score is equal to or greater than 30.

As you see in the screenshot below, our students have a better chance to pass the final exam with such conditions (Scott being particularly unlucky failing by just 1 point : )

More formula examples can be found in Excel IF OR functon.

In case you have to evaluate your data based on several sets of multiple conditions, you will have to employ both AND & OR functions at a time.

In the above table, suppose you have the following criteria to evaluate the students' success:

- Condition 1: column C>=20 and column D>=25
- Condition 2: column C>=15 and column D>=20

If either of the above conditions is met, the final exam is deemed passed, otherwise - failed.

The formula might seem tricky, but in a moment, you will see that it is not! You just have to express two conditions as AND statements and enclose them in the OR function since you do not require both conditions to be met, either will suffice:

`OR(AND(C2>=20, D2>=25), AND(C2>=15, D2>=20)`

Finally, use the above OR function as the logical test in the IF function and supply value_if_true and value_if_false arguments. As the result, you will get the following IF formula with multiple AND / OR conditions:

`=IF(OR(AND(C2>=20, D2>=25), AND(C2>=15, D2>=20)), "Pass", "Fail")`

The screenshot below indicates that we've got the formula right:

Naturally, you are not limited to using only two AND/OR functions in your Excel IF formulas. You can use as many logical functions as your business logic requires, provided that:

- In Excel 2016, 2013, 2010 and 2007, your formula includes no more than 255 arguments, and the total length of the formula does not exceed 8,192 characters.
- In Excel 2003 and lower, you can use up to 30 arguments and the total length of your formula shall not exceed 1,024 characters.

If you need to create more elaborate logical tests for your data, you can include additional IF statements in the value_if_true and value_if_false arguments of your Excel IF formulas. These multiple IF functions are called **nested IF functions** and they may prove particularly useful if you want your formula to return 3 or more different results.

Here's a typical example: suppose you want not simply to qualify the students' results as Pass/Fail, but define the total score as "*Good*", "*Satisfactory*" and "*Poor*". For instance:

- Good: 60 or more (>=60)
- Satisfactory: between 40 and 60 (>40 and <60)
- Poor: 40 or less (<=40)

To begin with, you can add an additional column (E) with the following formula that sums numbers in columns C and D:

`=C2+D2`

And now, let's write a nested IF function based on the above conditions. It's considered a good practice to start with the most important condition and make your functions as simple as possible. Our Excel nested IF formula is as follows:

`=IF(E2>=60, "Good", IF(E2>40, "Satisfactory", "Poor "))`

As you see, just one nested IF function is sufficient in this case. Naturally, you can nest more IF functions if you want to. For example:

`=IF(E2>=70, "Excellent", IF(E2>=60, "Good", IF(E2>40, "Satisfactory", "Poor ")))`

The above formula adds one more conditions - the total score of 70 points and more is qualified as "Excellent".

For more information about Excel IF with multiple conditions, please see How to use nested IF in Excel.

Like other Excel functions, IF can be used in array formulas. You may need such a formula if you want to evaluate every element of the array when the IF statement is carried out.

For example, the following array SUM/IF formula demonstrates how you can sum cells in the specified range based on a certain condition rather than add up the actual values:

`=SUM(IF(B1:B5<=1,1,2))`

The formula assigns a certain number of "points" to each value in column B - if a value is equal to or less than 1, it equates to 1 point; and 2 points are assigned to each value greater than 1. And then, the SUM function adds up the resulting 1's and 2's, as shown in the screenshot below.

Earlier in this tutorial, we've discussed a few IF formula examples demonstrating how to use the Excel IF function with logical functions AND and OR. Now, let's see what other Excel functions can be used with IF and what benefits this gives to you.

When discussing nested IF functions, we wrote the formula that returns different ranking (Excellent, Good, Satisfactory or Poor) based on the total score of each student. As you remember, we added a new column with the formula that calculates the total of scores in columns C and D.

But what if your table has a predefined structure that does not allow any modifications? In this case, instead of adding a helper column, you could add values directly in your If formula, like this:

`=IF((C2+D2)>=60, "Good", IF((C2+D2)=>40, "Satisfactory", "Poor "))`

Okay, but what if your table contains a lot of individual scores, say 5 different columns or more? Summing so many figures directly in the IF formula would make it enormously big. An alternative is embedding the SUM function in the IF's logical test, like this:

`=IF(SUM(C2:F2)>=120, "Good", IF(SUM(C2:F2)>=90, "Satisfactory", "Poor "))`

In a similar fashion, you can use other Excel functions in the logical test of your IF formulas:

**IF and AVERAGE:**

`=IF(AVERAGE(C2:F2)>=30,"Good",IF(AVERAGE(C2:F2)>=25,"Satisfactory","Poor "))`

The formulas retunes "Good" if the average score in columns C:F is equal to or greater than 30, "Satisfactory" if the average score is between 29 and 25 inclusive, and "Poor" if less than 25.

**IF and MAX/MIN:**

To find the highest and lowest scores, you can use the MAX and MIN functions, respectively. Assuming that column F is the total score column, the below formulas work a treat:

MAX: `=IF(F2=MAX($F$2:$F$10), "Best result", "")`

MIN: `=IF(F2=MIN($F$2:$F$10), "Worst result", "")`

If you'd rather have both the Min and Max results in the same column, you can nest one of the above functions in the other, for example:

`=IF(F2=MAX($F$2:$F$10) ,"Best result", IF(F2=MIN($F$2:$F$10), "Worst result", ""))`

In a similar manner, you can use the IF function with your custom worksheet functions. For example, you can use it with the GetCellColor / GetCellFontColor functions to return different results based on a cell color.

In addition, Excel provides a number of special IF functions to analyze and calculate data based on different conditions.

For example, to count the occurrences of a text or numeric value based on a single or multiple conditions, you can use COUNTIF and COUNTIFS, respectively. To find out a sum of values based on the specified condition(s), use the SUMIF or SUMIFS functions. To calculate the average according to certain criteria, use AVERAGEIF or AVERAGEIFS.

For the detailed step-by-step formula examples, check out the following tutorials:

- How to use the COUNTIF in Excel
- Using Excel COUNTIFS and COUNTIF with multiple conditions
- SUMIF in Excel - formula examples to conditionally sum cells
- How to use Excel SUMIFS and SUMIF with multiple criteria

You already know a way to spot blank and non-blank cells using the ISBLANK function. Microsoft Excel provides analogous functions to identify text and numeric values - ISTEXT and ISNUMBER, respectively.

Here's is example of the nested Excel IF function that returns "Text" if cell B1 contains any text value, "Number" if B1 contains a numeric value, and "Blank" if B1 is empty.

`=IF(ISTEXT(B1), "Text", IF(ISNUMBER(B1), "Number", IF(ISBLANK(B1), "Blank", "")))`

Sometimes, you can achieve the desired result by embedding the IF statement in some other Excel function, rather than using another function in a logical test.

Here's another way how you can use the CONCATINATE and IF functions together:

`=CONCATENATE("You performed ", IF(C1>5,"fantastic!", "well"))`

I believe you hardly need any explanation of what the formula does, especially looking at the screenshot below:

Both of the functions, IFERROR and IFNA, are used to trap errors in Excel formulas and replace them with another calculation, predefined value or text message. In earlier Excel versions, you can use the IF ISERROR and IF ISNA combinations instead.

The difference is that IFERROR and ISERROR handle all possible Excel errors, including #VALUE!, #N/A, #NAME?, #REF!, #NUM!, #DIV/0!, and #NULL!. While IFNA and ISNA specialize solely in #N/A errors.

Here is the simplest example of the IFERROR formula:

`=IFERROR(B2/C2, "Sorry, an error has occurred")`

As you see in the screenshot above, column D displays the quotient of the division of a value in column B by a value in column C. You can also see two error messages in cells D2 and D5 because everyone knows that you cannot divide a number by zero.

In some cases, however, you may not want to trap all errors, but rather test the condition causing a specific error. For example, to replace a divide by zero error with your own message, use the following IF formula:

`=IF(C2=0, "Sorry, an error has occurred", B2/C2)`

And that's all I have to say about using the IF function in Excel. I thank you for reading and hope to see you on our blog next week!

Excel formulas
CSV
Excel functions
Print
Financial functions
Vlookup
Merge data in Excel
SumIf
CountIf
Excel Compare
If statement
Excel Charts
Pivot Table
Conditional formatting
Excel formatting
Excel duplicates
Excel date
Excel tips
Excel macro
Outlook
Google Sheets
Outlook duplicates
Outlook templates

## 2,949 responses to "Excel IF statement with multiple AND/OR conditions, nested IF formulas, and more"

I need formula like ( my last year leave balance has 10 and current year leave 30 and this year consumed 03 now the balance will be 27 ignore balance another way need formula that if my last year leave -10 (negative) current Year 30 Balance = 20 in one cell Please do the needful.???any one

Hi,

I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail? What result do you want to get? Give an example of the source data and the expected result.

-----Staff Leaves Record----

Module 1

Opening Current Year Availed Leave Balance

*10 30 -2 28

*if this number is in positive then ignore in formula

Module 2

Opening Current Year Availed Leave Balance

*-5 30 -5 20

*If this number is in negative then adjusted and less in balance

now hope everything is clear

Hi,

Not sure if I understood your problem correctly. Try this formula

=IF(A1>=0,B1-C1,B1+A1-C1)

I hope it’ll be helpful.

Thanks!

I a trying to create an if function in excel 2016 with multiple layers:

if cell a1>50, cell a1*2,

if cell a1<50, cell a1*1,

if cell a1*1<20, must result as 20.

Please help.

Hello!

Please check out the following article on our blog, it’ll be sure to help you with your task: Excel nested IF statement - multiple conditions in a single formula.

I hope it’ll be helpful.

HI, I am trying to create a formula that looks across a range.

Example is:

I have to select one of three different results. FAIL, COMPLETE or CUSTOMER REFUND on a daily basis.

At the end of the week, I need to have a formula to say that if it has COMPLETE in the range (which are the days) then the final result should be COMPLETE. If it has anything else, it should be FAIL.

My issue is, that during the week, you could have a FAIL on Monday but a COMPLETE on Friday, so How do I get the formula to ignore the FAIL in this instance.

Hi,

I am not sure I fully understand what you mean. Unfortunately, without seeing your data it is difficult to give you any advice.

Please have a look at this articles - VLOOKUP with one or more criteria or COUNTIF with multiple criteria.

Or describe your problem in more detail. Include an example of the source data and the result you want to get. It’ll help me understand your request better and find a solution for you.

Sorry for misunderstanding.

In the top columns I have the days, in my sheet it would be C3:H3 (Mon-sat)

In columns A:B I have the customer name and order number.

So once I enter the order number and go to that particular day, I want to enter FAIL on whatever day the failed delivery was. Then when the problem is resolved I would enter either COMPLETE or CUSTOMER REFUND.

So at the end of the week against that order in I4,I should be able to see if the order was COMPLETED OR FAIL. So if they had a FAIL and CUSTOMER REFUND that would be COMPLETE, if they had a FAIL and COMPLETE, that would be COMPLETE but if they had a FAIL then that would be COMPLETE.

I did think maybe if I concatenated the selections, and then did an IF statement, but this is where I am stuck!

Hello!

If I understand your task correctly, the following formula should work for you:

=IF(SUM(--(C3:H3="Complete")) > 0,"Complete","Fail")

After that you can copy this formula down along the column.

I hope it’ll be helpful.

Thanks!

I have a range of cells that results in a text of "(All)"...when a selection is made, one of the range of cells will say something else, like, "January"....is there a way to have multiple conditions AND result in any text shown other than "(All)"?

Multiple conditions, and the "else" statement would be whatever that shows up other than "(All)"?

Hi,

I’m sorry but your task is not entirely clear to me. For me to be able to help you better, please describe your task in more detail. Please specify what you were trying to find, what formula you used and what problem or error occurred. Give an example of the source data and the expected result.

It’ll help me understand it better and find a solution for you.

Hi I am a bit of an excel novice and I, like many, I don't know what I don't know

I am currently using this formula =IF(I14<$G$9,0,IF(I1465,$W$9))) to determine value in a cell for the following conditions

- if age (F14) is less than planned retirement age (SG$9) then pension income is $0

- if age (F14) is <=65 but greater than retirement age ($G$9) then pension income is $T$9

- if age (F14) is greater than 65, then pension income is $W$9

But; the stated pension incomes ($T$9 and $W$9) are indexed to inflation and I cannot figure out how to accommodate the ever increasing values. Any suggestions or help would be really appreciated

Hello!

If I understand your task correctly, you can manually change the values in $T$9 and $W$9. Also in these cells it is possible to use a reference to a cell with an actual value or a hyperlink.

I hope I answered your question. If something is still unclear, please feel free to ask.

I have to come up with a function with the criteria...

D2>5

G2= "B" or "C" or "D"

E2= "marketing" or "finance"

and then if those are true then C2* $Q$23 otherwise 0 is left in the cell.

Hi,

I hope you have studied the recommendations in the tutorial above. It contains answers to your question

This is the formula I came up with, can you help me with what I have wrong, thanks!

=IF(AND(D2>5,OR(G2="B",G2="C",G2="D",OR(E2="Marketing",E2="Finance")))),C2*$Q$23,0)

Hello!

Please use the following formula

=IF(AND(D2>5,OR(G2="B",G2="C",G2="D",OR(E2="Marketing",E2="Finance"))),C2*$Q$23,0)

Hi

Im using the following formula but it doesnt seem to be working

=IF(OR(J1080:J20001="AUD","2021","2020","2019","2018","2017","2016"),'Economic Assumptions - Forex'!$M$9*K1080)=(OR(J1080:J20001="ZAR","2021","2020","2019","2018","2017","2016"),'Economic Assumptions - Forex'!$M$16*K1080)

Please can you tell me what is wrong

Hello!

I can’t test your formula as it contains unique references to your data. I do not have this data.

However, the condition

(J1080:J20001=”AUD”,”2021″,”2020″,”2019″,”2018″,”2017″,”2016″)

is incorrect. Can only be used

(J1080:J20001=”AUD”,J1080:J20001=”2021″, J1080:J20001=”2020″, J1080:J20001=”2019″, J1080:J20001=”2018″, J1080:J20001=”2017″,J1080:J20001=”2016″)

I hope it’ll be helpful.

I am getting the error message too mant arguements. Is there a way to have more than 2 options in an IF statement?

=IF(I3="USD",$B$1*G3,IF(I3="GBP",$D$1*G3),IF(I3="CAD",$F$1*G3),0)

This equation should work better for you. I took out your unnecessary brackets that had caused the "too many arguments" notifications. (You had your "false" outside of the conditions.)

=IF(I3="USD",$B$1*G3,IF(I3="GBP",$D$1*G3,IF(I3="CAD",$F$1*G3,0)

Hope this works!

Hello!

Please try the following formula:

=IF(I3="USD",$B$1*G3,IF(I3="GBP",$D$1*G3,IF(I3="CAD",$F$1*G3,0)))

I hope it’ll be helpful.

Can I convert 1.0 into 50 then 5.0 into 0?

Lets say

I have 1.0 -5.0 then I wan between 50 - 0 so the value of 1.0 is 50 then if it 1.1 that's 49 how would I convrt 2.8 into its specific range

Hi,

Try the following formula:

=50-(A1-1)*10

Hi! I am trying to have a cell return a value based on whether other values in the same row are greater than zero. To give more detail, the data is tracking steps in a hiring process, each column is a step in the process and the users will enter the date when that step is completed. I’d like to have an additional column that will say what step in the process that candidate is currently in. In other words, if for candidate A the most recent date entered is under the “interview complete” column, how do I make another column that will return “interview complete” as a value for candidate A?