Excel IF statement with multiple AND/OR conditions, nested IF formulas, and more

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.

How to use Excel IF function with multiple conditions

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.

Example 1. Using IF & AND function in Excel

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:
Excel IF function with multiple AND conditions

Note. Microsoft Excel checks all conditions in the AND function, even if one of the already tested conditions evaluates to FALSE. Such behavior is a bit unusual since in most of programming languages, subsequent conditions are not tested if any of the previous tests has returned FALSE.

In practice, a seemingly correct IF / AND formula may result in an error because of this specificity. For example, the formula =IF(AND(A2<>0,(1/A2)>0.5),"Good", "Bad") will return "Divide by Zero Error" (#DIV/0!) if cell A2 is equal to 0. The avoid this, you should use a nested IF function:

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

Example 2. Using IF with OR function in Excel

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 : )
An example of IF/OR formula

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

Example 3. Using IF with AND & OR functions

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:
Using IF with OR & AND functions

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.

Using multiple IF statements in Excel (nested IF functions)

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

An additional column that sums numbers in columns C and D

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".

An example of nested IF functions

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

Using Excel IF in array formulas

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:


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.
Using Excel IF in array formulas

Note. Since this is an array formula, remember to press Ctrl + Shift + Enter to enter it correctly.

Using IF function together with other Excel functions

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.

Example 1. Using IF with SUM, AVERAGE, MIN and MAX functions

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 "))
Using IF with the SUM function

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


=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.


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", ""))
Using IF with the MIN and MAX functions

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:

Example 2. IF with ISNUMBER and ISTEXT functions

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", "")))
Using IF with ISNUMBER, ISTEXT and ISBLANK functions

Note. Please pay attention that the above formula displays "Number" for numeric values and dates. This is because Microsoft Excel stores dates as numbers, starting from January 1, 1900, which equates to 1.

Example 3. Using the result returned by IF in another Excel function

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!", "good"))

I believe you hardly need any explanation of what the formula does, especially looking at the screenshot below:
Using the result returned by IF in another Excel function

IF function vs. IFERROR and IFNA

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")
An example of using the IFERROR function in Excel

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!

You may also be interested in:

1,740 Responses to "Excel IF statement with multiple AND/OR conditions, nested IF formulas, and more"

  1. Agyemang Badu says:

    Hi,can you write a formula for the follow these question for me,
    IF cell A1 = JENNIFER then value will be 2000
    IF cell C1 is less than 40 multiply it by 2
    IF cell C1 is grreater than or equal to 40 but less than 100, then multiply it by 4

  2. Sajjad says:

    Hi Everybody,
    I have a problem in if function with following conditions:
    1. I have 4 words in C3, C4, C5 & C6 and each word has condtion 1 and otherwise condition 2 if not returns false
    2. I want to add both conditions againt each word in a single formula
    I.e. if(C3="a", condition 1, condition 2, if(C3="b", condition 1, condition 2, if(C3="c", condition 1, condition 2, if(C3="d", condition 1, condition 2))))

    But it does not help me out.

    Requested to please help me in this regards


  3. Dan says:

    I'd like to create a formula for a calculation:

    Up to $100,000 total price, the cost is $5.75 per $1,000 of price.

    Above $100,000 total price, the cost is $575 plus $5.00 per $1,000 of price.

    Thank you!

  4. Vivek Sahai says:

    I wish to know how to use IF formula for conditions as under:
    1: M-W:I/II T-S:III/IV =1
    2: M-W:I/II =.5
    3: M/T:I W/T:II F/S III =1
    4: M/T:I =.5

  5. Vicky says:

    I have three suppliers like A B C,the three suppliers given material price ,i should format three column now i want least supplier name in new column, how to i calculate this format in excel

  6. Susan Shao says:

    I am trying to convert to date format from column A "20190520" to column B "05/20/2019"
    please advise. Thanks in advance.

    • Becky says:

      highlight column, click "text to columns" in the data tab. Then bubble in delimited, click "next" twice, bubble in Date and use "YMD" in the dropdown and click finish.

  7. Feroz says:

    Hi Friends,
    Could you help me with the below example.
    if we have 1000 in one column which is splitted in many values in another column with 20000, how to total only 10000.
    In the below example you may see, for each day, we have same amount in two columns but these amount are splitted in third column, how can we match these. Any suggestions.
    Monday 1000 2000 500
    Monday 1000 2000 500
    Monday 1000 2000 500
    Monday 1000 2000 500
    Monday 1000 2000 500
    Monday 1000 2000 250
    Monday 1000 2000 250
    Tuesday 2900 1100 750
    Tuesday 2900 1100 750
    Tuesday 2900 1100 600
    Tuesday 2900 1100 500
    Tuesday 2900 1100 500
    Tuesday 2900 1100 450
    Tuesday 2900 1100 450
    Wednesday 1500 2500 750
    Wednesday 1500 2500 750
    Wednesday 1500 2500 1000
    Wednesday 1500 2500 1000
    Wednesday 1500 2500 250
    Wednesday 1500 2500 250
    Thurday 2250 2750 1000
    Thurday 2250 2750 750
    Thurday 2250 2750 250
    Thurday 2250 2750 2000
    Thurday 2250 2750 1000
    Friday 8450 1550 450
    Friday 8450 1550 550
    Friday 8450 1550 2000
    Friday 8450 1550 3000
    Friday 8450 1550 1000
    Friday 8450 1550 1000
    Friday 8450 1550 2000
    Please help.

  8. Shwetha says:

    I have two Special Handling Codes one is 6YU and another 6ZO
    We have 3 customers
    If I choose 6YU SPH answer should be either this APD SHENZHEN DK INC, or this ASIAN POWER DEVICES INC customer
    If I choose 6ZO SPH answer should be SENERGY TECHNOLOGY(SHENZHEN)CO.,LTD
    Can you please help me out of this by using IF formula

  9. Melchie says:

    Hello, i have a something to ask. :)
    What will be my formula if I will write
    Always and on the other column and it will automatically respond "5"?
    Always - 5
    Most of the Time 4
    Sometimes - 3
    Seldom - 2
    Never - 1

  10. Sam says:

    Hello Can someone please help me. I need to trun this formula to a 4 clause insted of 3

    I need to change it to...

    0$ to 24.99 0%.... 25 to 34.99 3%...... 35 to 41.99 5%.... 42+ 8%

  11. Khan says:

    hi, i am trying to write a formula for the following:

    1) if R49 is less then 1825 days then M49*50% and if R49 is greater then 1825 days then M49*100%.
    2) and if between these two so pick 50% and 100% Proportionate basis.

    Kindly help

  12. Abdullahi says:

    i am new to excel but i want the value in a cell to be either 7 or 12

  13. Noor Ebrahim says:

    I have question if the condition as follow then how the if formula will be transit
    If the total portfolio is 600000 and the condition say that
    From 0 - 300000 you get $1.5/1000 then
    From 300001 - 500000 you get $2/1000 then
    Above 500001 you get $2.5/1000.
    For example if I bring total portfolio $600,000 then for first $ 300,000 I will get (300000/1000*1.5) = 450. Then rest $100,000 I will get (100000/1000*2) = 200 and last $100,000 I will get (100000/1000*2.5) = 250. So total I get = 450 + 200 + 250 =900. How can I do the above in if statement?

  14. Ali says:

    i want to convert sign of calculation values like in one cell i have these values "=-4896.71-190+3613.39+90+5086.71" and i need "=+4896.71+190-3613.39-90-5086.71" how i change their signs.

    Thanks in advance

  15. David says:

    Add 10000 if 1.98% of the principal is greater than 2000 if not less 1000

  16. Atta says:

    Hi kindly help me to do this.
    I have a value in Cell A1. I needs to do that When I type "Yes" in cell A2 then the value of A1 shows as a result in Cell A3.

  17. Atta says:

    Hi kindly help me to do this.
    I have a value in Cell A1. I needs to do that When I put value as "Yes" in cell B1 then the cell C1 pick the value of cell A1 automatically. And if I put value as "No" in cell B1 then the cell C1 pick 0 as a value automatically.

  18. SINGHU says:

    hi, i am trying to use OR & AND operator in the following condition but it is not working so please help me in writing the formula
    if (A1>0), A1*5*100, OR (B1>0), B1*100 AND (A1>0,B1>0),A1*5*100+B1*100, and if (C1>0) add 0 to previous result or if (D1>0), add 0 and if (C1>0,D1>0) add 0 to the above result
    i tried many times to write the formula by myself but still error message is showing. please kindly help me

    with regards

  19. Ash says:

    Hi, I am trying to write a formula for the following:

    Cell A1 is a Number ranging between 0 & 400. I want Cell A3 to display the following:
    If Cell A1 is between 0 - 99 = "Text 1"
    If Cell A1 is between 100 - 249 = "Text 2"
    If Cell A1 is 250+ = "Text 3"

    I can make it work for Text 1 & Text 2 but adding a third, breaks the formula...

    If anyone can help me with this, that would be great.



  20. James says:

    Im trying to put values based on country... But I want to be able to change them in one worksheet and they reflect in another... Now is there a way I can make a command/statement which can make excel automatically add a row or column in another worksheet if I input a new country that was not originally specified??

  21. aditya says:

    Hi Svetlana
    Need your help and guidance to solve the following problem

    I have set of 85 readings of at test done on a unit taken from DAQ (Data acquisition system), and i have populated in a table in excel. Now i need to insert a condition in the cell, specifying that if any five consecutive readings taken from the 85 readings surpasses number "100" than the test is failed , if no five consecutive readings surpasses number "100" than test is " Passed"

    Hope the above info is enough for you to solve the problem.

    Best Regards

  22. Benjamin C Harper says:

    Can someone help me write a formula that searches a list of data to see if the word Holiday is in there, if it is it sums all the other data together except that cell. If it doesn't find the word then it sums all the data in the column. If all cells are empty it returns an empty cell.


  23. KESHAB MAINALI says:

    Hi, can someone help me to create formula according to below condition??
    Table 1
    Type>> 6-800 6-500 6-100 6-200
    Book $10.00 $15.00 $- ??
    Table $100.00 $- $200.00 ??
    Copy $5.00 $10.00 $30.00 ??
    Pen $7.00 $8.00 $- ??
    Pencil $2.00 $3.00 $- ??
    Paper $1.00 $2.00 $5.00 ??

    Table 2
    Item Type Price
    6-800 Book $10.00
    6-800 Table $100.00
    6-800 Copy $5.00
    6-800 Pen $7.00
    6-800 Pencil $2.00
    6-800 Paper $1.00
    6-500 Book $15.00
    6-500 Copy $10.00
    6-500 Pen $8.00
    6-500 Pencil $3.00
    6-500 Paper $2.00
    6-100 Table $200.00
    6-100 Copy $30.00
    6-100 Paper $5.00
    6-200 Book $100.00
    6-200 Pencil $50.00
    6-200 Paper $10.00

    I want the formula which will fill the Table 1 with data from Table two.
    Condition are if Type & Item from Table 1 matches with single column(Item Type) of Table 2 than return value form Price column.
    Thank you,

  24. Jeff says:

    I have a question if I have
    A1 = keep the change
    B1 = 0.50

    I would like a formula for whenever I have keep the change it's will always give me the next cell reference for example in Sheet 2. A1 = same and B1 = equal the same number. What formula should I use to get that. Please let me know thanks.

  25. Jyoti says:

    I trying to apply the if formula but i was failed every time please help me out.
    my concern is that i need if value is less than 12000 than i get result 2% of value otherwise get 25% .please give me solution

  26. jUDY says:


  27. Vitalis says:

    I have been trying to nest an IF formula with 5 rage but 6 of them are not working out. Please let me know if you have the same issue.
    =IF(H104>15,"E",IF(H104>11,"D",IF(H104>8,"C",IF(H104>4,"B", "A"))))
    Vlookup Table

  28. Laya martinez says:

    I want to write a formula:

    If column B2 is higher than 10000 and lower than 20000, put 100 in column c2

  29. Nikhil says:

    I need to get the formula for below
    I have 3 scenario's as below

    1 Night = $ 8.5
    2 Night = $ 17
    3 Night & Above = $ 22
    My report comes with the number of nights guest stayed I want to to pick the total amount if guest stayed for 1 night then to pick $8.5, if for 2 nights then $ 17 and if for 3 night& above $22

  30. Praveen says:

    Kindly help with suitable formula for C=A-B but should not exceed 15000

  31. Joe says:

    I have a complex if statement to create a dashboard that I need to amend to use data from other worksheets. When I select 'Cats' or 'Dogs from the drop down, the relevant information SHOULD be displayed in the dashboard 'feed plan' eg:
    =IF(AND($J$1"All Pets",$J$1Q4),0,OFFSET(Cats!$B$1,'feed plan'!$I3,'feed plan'!J$3))
    Where 'All Pets' and 'Cats' are tables. I want to update this to use the data in table 'Dogs'. Every time I change 'Cats' to 'Dogs in the IF..statement the information in 'feed plan' that should stay as 'cats' is updated with 'Dogs'. What am I doing wrong?

  32. Tam says:

    I have different currency rates which I want have an IF function to link the correct rate to a different tab depends on what currency on that tab is. Below is my example
    FX Rate 1.3036 1.1198

    If my next tab currency is CAD, I would like the rate for it to automatically equal 1.3.36, otherwise, it will be 1.1198.

    Can someone help me with a formula for it?
    Thanks in advance

  33. Joe Lee says:

    Please help me.
    In two different rows with two columns. The first column (A) will contain the value and the next column (B) will contain the calculated value (formula). A formula has been entered in the first row of the second column (B1) and it has been extended down to the second row (B2) using the fill handle tool. (Say if A1 is 50, a student has "passed", and if not the student has "failed"). No values have been entered in either of the cells that should contain the data. By this the cells containing the formula will show "failed" since no value has been entered in the columns containing the the data.
    I want a formula if I enter a value in A1, it will show the results in the next column but the whole row of row 2 containing any data should go off/clear off including the calculated results "failed".

  34. Debbie Middendorf says:

    How would I combine these 3 formulas
    Basically I need to look at the amount in B5 and if it's greater than 98 return 200.00 if between 90-97 return 100.00 and if under 90.00 return 0.00
    I have the 3 separate formulas but can't seem to get them into one formula.


Post a comment

Unfortunately, due to the volume of comments received we cannot guarantee that we will be able to give you a timely response. When posting a question, please be very clear and concise. We thank you for understanding!
Ultimate Suite 2018.5 for Excel
60+ professional tools for Excel 2019-2007 to do your daily work
Incredible product, even better tech support…AbleBits totally delivers!
Deborah Bryant
Anyone who works with Excel is sure to find their work made easier
Jackie Lee
The best spent money on software I've ever spent!
Patrick Raugh
Ablebits is a fantastic product - easy to use and so efficient.
Debra Celmer
Excel is at its best now
Annie C.
I don't know how to thank you enough for your Excel add-ins
Jennifer Morningstar
Anybody who experiences it, is bound to love it!
Kumar Nepa
AbleBits suite has really helped me when I was in a crunch!
Nelda Fink
I have enjoyed every bit of it and time am using it
Christian Onyekachi Nwosu
It's the best $100 we've ever spent!
Mike Cavanagh
I love the program, and I can't imagine using Excel without it!
Robert Madsen
One word… WOW!
Dave Brown
Love the products!
David Johnston
It is like having an expert at my shoulder helping me…
Linda Shakespeare
Your software really helps make my job easier
Jeannie C.
Thanks for a terrific product that is worth every single cent!
Dianne Young
I love your product
Brad Gibson
Sheila Blanchard