Excel IF statement with multiple conditions

The tutorial shows how to create multiple IF statements in Excel with AND as well as OR logic. Also, you will learn how to use IF together with other Excel functions.

In the first part of our Excel IF tutorial, we looked at how to construct a simple IF statement with one condition for text, numbers, dates, blanks and non-blanks. For powerful data analysis, however, you may often need to evaluate multiple conditions at a time. The below formula examples will show you the most effective ways to do this.

How to use IF function with multiple conditions

In essence, there are two types of the IF formula with multiple criteria based on the AND / OR logic. Consequently, in the logical test of your IF formula, you should use one of these functions:

  • AND function - returns TRUE if all the conditions are met; FALSE otherwise.
  • OR function - returns TRUE if any single condition is met; FALSE otherwise.

To better illustrate the point, let's investigate some real-life formulas examples.

Excel IF statement with multiple conditions (AND logic)

The generic formula of Excel IF with two or more conditions is this:

IF(AND(condition1, condition2, …), value_if_true, value_if_false)

Translated into a human language, the formula says: If condition 1 is true AND condition 2 is true, return value_if_true; else return value_if_false.

Suppose you have a table listing the scores of two tests in columns B and C. To pass the final exam, a student must have both scores greater than 50.

For the logical test, you use the following AND statement: AND(B2>50, C2>50)

If both conditions are true, the formula will return "Pass"; if any condition is false - "Fail".

=IF(AND(B2>50, B2>50), "Pass", "Fail")

Easy, isn't it? The screenshot below proves that our Excel IF /AND formula works right: Excel IF statement with multiple AND conditions

In a similar manner, you can use the Excel IF function with multiple text conditions.

For instance, to output "Good" if both B2 and C2 are greater than 50, "Bad" otherwise, the formula is:

=IF(AND(B2="pass", C2="pass"), "Good!", "Bad") Excel IF function with multiple text conditions

Important note! The AND function checks all the conditions, even if the already tested one(s) evaluated 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 statement may result in an error because of this specificity. For example, the below formula would return #DIV/0! ("divide by zero" error) 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")

For more information, please see IF AND formula in Excel.

Excel IF function with multiple conditions (OR logic)

To do one thing if any condition is met, otherwise do something else, use this combination of the IF and OR functions:

IF(OR(condition1, condition2, …), value_if_true, value_if_false)

The difference from the IF / AND formula discussed above is that Excel returns TRUE if any of the specified conditions is true.

So, if in the previous formula, we use OR instead of AND:

=IF(OR(B2>50, B2>50), "Pass", "Fail")

Then anyone who has more than 50 points in either exam will get "Pass" in column D. With such conditions, our students have a better chance to pass the final exam (Yvette being particularly unlucky failing by just 1 point :) Excel IF function with multiple OR conditions

Tip. In case you are creating a multiple IF statement with text and testing a value in one cell with the OR logic (i.e. a cell can be "this" or "that"), then you can build a more compact formula using an array constant.

For example, to mark a sale as "closed" if cell B2 is either "delivered" or "paid", the formula is:

=IF(OR(B2={"delivered", "paid"}), "Closed", "")

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

IF with multiple AND & OR statements

If your task requires evaluating several sets of multiple conditions, you will have to utilize both AND & OR functions at a time.

In our sample table, suppose you have the following criteria for checking the exam results:

  • Condition 1: exam1>50 and exam2>50
  • Condition 2: exam1>40 and exam2>60

If either of the conditions is met, the final exam is deemed passed.

At first sight, the formula seems a little tricky, but in fact it is not! You just express each of the above conditions as an AND statement and nest them in the OR function (since it's not necessary to meet both conditions, either will suffice):

OR(AND(B2>50, C2>50), AND(B2>40, C2>60)

Then, use the OR function for the logical test of IF and supply the desired value_if_true and value_if_false values. As the result, you get the following IF formula with multiple AND / OR conditions:

=IF(OR(AND(B2>50, C2>50), AND(B2>40, C2>60), "Pass", "Fail")

The screenshot below indicates that we've done the formula right: IF with multiple AND & OR statements

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

  • In Excel 2007 and higher, you have no more than 255 arguments, and the total length of the IF formula does not exceed 8,192 characters.
  • In Excel 2003 and lower, there are no more than 30 arguments, and the total length of your IF formula does not exceed 1,024 characters.

Nested IF statement to check multiple logical tests

If you want to evaluate multiple logical tests within a single formula, then you can nest several functions one into another. Such functions are called nested IF functions. They prove particularly useful when you wish to return different values depending on the logical tests' results.

Here's a typical example: suppose you want to qualify the students' achievements as "Good", "Satisfactory" and "Poor" based on the following scores:

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

Before writing a formula, consider the order of functions you are going to nest. Excel will evaluate the logical tests in the order they appear in the formula. Once a condition evaluates to TRUE, the subsequent conditions are not tested, meaning the formula stops after the first TRUE result.

In our case, the functions are arranged from largest to smallest:

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

Naturally, you can nest more functions if needed (up to 64 in modern versions). Nested IF statement in Excel

For more information, please see How to use multiple nested IF statements in Excel.

Excel IF array formula with multiple conditions

Another way to get an Excel IF to test multiple conditions is by using an array formula.

To evaluate conditions with the AND logic, use the asterisk:

IF(condition1) * (condition2) * …, value_if_true, value_if_false)

To test conditions with the OR logic, use the plus sign:

IF(condition1) + (condition2) + …, value_if_true, value_if_false)

To complete an array formula correctly, press the Ctrl + Shift + Enter keys together. In Excel 365 and Excel 2021, this also works as a regular formula due to support for dynamic arrays.

For example, to get "Pass" if both B2 and C2 are greater than 50, the formula is:

=IF((B2>50) * (C2>50), "Pass", "Fail") IF array formula with multiple AND conditions

In my Excel 365, a normal formula works just fine (as you can see in the screenshots above). In Excel 2019 and lower, remember to make it an array formula by using the Ctrl + Shift + Enter shortcut.

To evaluate multiple conditions with the OR logic, the formula is:

=IF((B2>50) + (C2>50), "Pass", "Fail") IF array formula with multiple OR conditions

Using IF together with other functions

This section explains how to use IF in combination with other Excel functions and what benefits this gives to you.

Example 1. If #N/A error in VLOOKUP

When VLOOKUP or other lookup function cannot find something, it returns a #N/A error. To make your tables look nicer, you can return zero, blank, or specific text if #N/A. For this, use this generic formula:

IF(ISNA(VLOOKUP(…)), value_if_na, VLOOKUP(…))

For example:

If #N/A return 0:

If the lookup value in E1 is not found, the formula returns zero.

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), 0, VLOOKUP(E1, A2:B10, 2, FALSE))

If #N/A return blank:

If the lookup value is not found, the formula returns nothing (an empty string).

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), "", VLOOKUP(E1, A2:B10, 2, FALSE))

If #N/A return certain text:

If the lookup value is not found, the formula returns specific text.

=IF(ISNA(VLOOKUP(E1, A2:B10, 2,FALSE )), "Not found", VLOOKUP(E1, A2:B10, 2, FALSE)) If #N/A error in VLOOKUP

For more formula examples, please see VLOOKUP with IF statement in Excel.

Example 2. IF with SUM, AVERAGE, MIN and MAX functions

To sum cell values based on certain criteria, Excel provides the SUMIF and SUMIFS functions.

In some situations, your business logic may require including the SUM function in the logical test of IF. For example, to return different text labels depending on the sum of the values in B2 and C2, the formula is:

=IF(SUM(B2:C2)>130, "Good", IF(SUM(B2:C2)>110, "Satisfactory", "Poor"))

If the sum is greater than 130, the result is "good"; if greater than 110 – "satisfactory', if 110 or lower – "poor". Using the IF function with SUM

In a similar fashion, you can embed the AVERAGE function in the logical test of IF and return different labels based on the average score:

=IF(AVERAGE(B2:C2)>65, "Good", IF(AVERAGE(B2:C2)>55, "Satisfactory", "Poor"))

Assuming the total score is in column D, you can identify the highest and lowest values with the help of the MAX and MIN functions:

=IF(D2=MAX($D$2:$D$10), "Best result", "")

=IF(D2=MAX($D$2:$D$10), "Best result", "")

To have both labels in one column, nest the above functions one into another:

=IF(D2=MAX($D$2:$D$10), "Best result", IF(D2=MIN($D$2:$D$10), "Worst result", "")) Using IF together with the MIN and MAX functions

Likewise, you can use IF together with your custom functions. For example, you can combine it with GetCellColor or GetCellFontColor to return different results based on a cell color.

In addition, Excel provides a number of functions to calculate data based on conditions. For detailed formula examples, please check out the following tutorials:

  • COUNTIF - count cells that meet a condition
  • COUNTIFS - count cells with multiple criteria
  • SUMIF - conditionally sum cells
  • SUMIFS - sum cells with multiple criteria

Example 3. IF with ISNUMBER, ISTEXT and ISBLANK

To identify text, numbers and blank cells, Microsoft Excel provides special functions such as ISTEXT, ISNUMBER and ISBLANK. By placing them in the logical tests of three nested IF statements, you can identify all different data types in one go:

=IF(ISTEXT(A2), "Text", IF(ISNUMBER(A2), "Number", IF(ISBLANK(A2), "Blank", ""))) IF with ISNUMBER, ISTEXT and ISBLANK

Example 4. IF and CONCATENATE

To output the result of IF and some text into one cell, use the CONCATENATE or CONCAT (in Excel 2016 - 365) and IF functions together. For example:

=CONCATENATE("You performed ", IF(B1>100,"fantastic!", IF(B1>50, "well", "poor")))

=CONCAT("You performed ", IF(B1>100,"fantastic!", IF(B1>50, "well", "poor")))

Looking at the screenshot below, you'll hardly need any explanation of what the formula does: Using IF and CONCATENATE

IF ISERROR / ISNA formula in Excel

The modern versions of Excel have special functions to trap errors and replace them with another calculation or predefined value - IFERROR (in Excel 2007 and later) and IFNA (in Excel 2013 and later). 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.

For example, to replace the "divide by zero" error (#DIV/0!) with your custom text, you can use the following formula:

=IF(ISERROR(A2/B2), "N/A", A2/B2) Using IF together with ISERROR

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!

Practice workbook for download

Excel IF multiple criteria - examples (.xlsx file)

4538 comments

  1. Here is my issue:
    =IF(AND(I4="Residential",J4="Self-Generated"),8%,6%)
    which I can get to calculate perfectly but I need it to have 4 conditions
    =IF(AND(I4="Residential",J4="Self-Generated"),8%,6%, AND (I4="Commercial",J4="Self-Generated"),10%,8%)
    which I can not get to work.

    If Residential & Self-Generated 8%
    If Residential & Company Generated 6%
    If Commercial & Self-Generated 10%
    If Commerical & Company Generated 8%

    Any help would be appreciated.

    • Hello!
      Carefully read the recommendations in the article above. The formula might be something like this:

      =IF(AND(I4="Residential",J4="Self-Generated"),8%, IF(AND(I4="Residential",J4="Company Generated"),6%, IF(AND(I4="Commercial",J4="Self-Generated"),10%, IF(AND(I4="Commercial",J4="Company Generated"),8%,""))))

  2. I have the following COUNTIFS formula:

    =COUNTIFS($D$2:$D$494,A15,$C$2:$C$494,"A1",$N$2:$N$494,"<=15%")

    which works fine. However when I try to replace "15%" with a reference to a standalone cell containing a drop down with varying percentages, the formula returns an answer of "0".

    I have played with the formula for a few days and have to admit I am stumped. There is probably a simple solution but it escapes me.

    Any help would be greatly appreciated.

  3. Hi

    I am trying to create an IF function where the following is applicable:
    Cell C4 has 3 options, "Yes", "N/A" and "No"
    Cell C5 has 3 options, "Yes", "N/A" and "No"
    Cell C6 has 3 options, "Yes", "N/A" and "No"

    Cell C7 contains the IF statement whereby if Cell C4 is Yes or N/A, Cell C5 is Yes or N/A and Cell C6 is Yes or N/A the result should be "Positive". Any "No" in Cell C4, C5 and C6 should be "Negative"

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

      =IF(OR(C4="No", C5="No", C6="No"),"Negative","Positive")

      • I have a similar question to the original and I have the following formula in my spreadsheet -

        =IF(OR(H10="n",H11="n",H12="n"),"n", "y")

        My question is - how can I make the formula so that when all 3 cells are blank (haven't been tested yet) that the cell with the formula is blank? As the formula is now, that cell has a value of "y" and I haven't scored/populated the other cells yet.

        If I take out the "y" and just leave "" - I won't get a return of "y" when all 3 cells are "y" - it will just be blank.

          • Hi - Thank you for answering my question so quickly. I believe I figured out a solution that took care of everything that I needed in the formula, (not just fiuring out how to leave the fomula cell blank - as I originally asked for your help with).

            I used -
            =IF(OR(H10:H13="n"),"n",IF(AND(H10:H13="x"),"x",IF(OR(H10:H13="y","x"),"y","")))

            That way my formula cell will be able to populate for any of the 3 possible answers - y, n and x (n/a) and remain blank until the other cells are populate.

            Thanks again, I really appreciate it! :)

  4. After IF, I need to use multiple AND and OR conditions and give multiple values for true and false accordingly, how do I do that

  5. Column A has a number and I need column B to be equal to column A, unless it’s it less than 2 I want it to be equal to 2.

  6. I am wracking my brain trying to sort my conundrum.

    I have 3 values Weekly(C5), 4 weekly(D5) and Monthly(E5) (which can all be inputted manually)

    I am trying to write the correct IF statement that allows me to create a yearly figure from only one of these values.

    e.g. if a user enters a figure in C5 the output would be C5*12, if users enter a figure D5 then the output would be D5*13 and finally, if the user enters a figure E5 then the output is E5*12.

    My problem is that I am only looking to output one of these figures to F5 as a yearly.

    I would appreciate some advice as I have looked at nested IFs and tried to use the conditions around C5=0, c5>=0. I have figured this out for using only 2 potential values but when I add in the 3rd I can't seem to figure out how to include/combine the other cells' values e.g. E=0, E5>=0 to give me the option of only one of the calculations working to give me a yearly.

    would appreciate any advice around this. TIA

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

      =IF(C5>0,C5*12,IF(D5>0,D5*12,IF(E5>0,E5*12,"")))

      I hope this will help

  7. HI,

    how can I combine the following:

    =IF((L2-M2)0,(L2-M2),0)

    Thank you for help.

  8. Very useful article, It helped me a lot.
    Thanks!!

  9. =IF(A3=1,"A",IF(A3=2,"B",IF(A3=3,"C",IF(A3=4,"D",IF(A3=5,"E",IF(A3=6,"F",IF(A3=7,"G",IF(A3=8,"H",IF(A3=9,"I",IF(A3=0,"X"))))))))))

    This 1= A 2= B i need to an formula to comnine if 1234 it should be abcd if it is 4321 it should be dcba could you please help me with this

  10. Could you please help me to make a formula that produces a list of each class and the minimum mark in that class in a sheet that have all classes mixed together
    Like if I have all marks of 6A and 6B and 6C and I want a table with one column for class and one for minimum mark in that class

  11. I am attempting to combine these two IF commands into one.

    =IF(O2>=0.2,"",C2)

    =IF(C2="A1","A",IF(C2="A2","AA",IF(C2="A3","AAA")))

    I have tried combining them with AND, but without success. I am stumped!

    Any help would be greatly appreciated.

    • Hello!
      I’m sorry but your description doesn’t give me a complete understanding of your task. Correct me if I’m wrong, but I believe the formula below will help:

      =IF(O2>=0.2,"",IF(C2="A1","A",IF(C2="A2","AA",IF(C2="A3","AAA"))))

      • Many thanks. That worked. I now see where I was in error, which was including "C2" in the first IF command.

  12. Please Help with below formula, How to use both formula into single statement

    we have 2 condition

    =IF(AND(A1>0,B1="MIS"),"40","20")

    =IF(AND(A1>=0,B1="NRML"),"50","100")

    • Hi!
      These expressions cannot be combined in one formula. If the first condition returns FALSE, should the formula return 20 or should the second condition be tested?

  13. Good day
    im trying to seperate this list using if formula
    1968
    19230
    2068
    20230
    2168
    4968
    63230
    6568
    66230
    68230
    6968
    101230
    102230
    10468
    and i have tried to use this formula =IF(P6=LEN(4),RIGHT(P6,2),RIGHT(P6,4))
    i want it to look like this
    19 68
    19 230
    how best can i solve this

  14. Hi,

    Having trouble with this..

    =IF(OR(AND(H8=0,F8=100%,K3="FINALED"),AND(H8=0,F8=100%,K3="N/A"),"ready to pay","not ready to pay")

    I'm looking for the same statements to come up whether or not k3="FINALED" OR "N/A".

    How can I make that happen?

    • Hi!
      I don't really understand what result you want to get, but try this formula:

      =IF(OR(AND(H8=0,F8=100%,K3="FINALED"), AND(H8=0,F8=100%,K3="N/A")), "ready to pay","not ready to pay")

      If this is not what you wanted, please describe the problem in more detail.

      • Alexander,

        The result I need is either "not ready to pay" or "ready to pay".

        If all 3 logical expressions are not met, my result should be "not ready to pay". If they are all met, then I need the contrary. My issue was getting to the same two conclusions with the exception of k3="n/a" or "finaled".

        The formula you sent did it! Thank you

  15. Hi there are two formulas in the sheet and want to make it single.

    =IF((A10),"Under Process","0")

    I tried below formula but it's not worked.
    =IF(OR(A1>0,"Under Process"),IF(B1<C1,"Claim","Not Claim"),0)

    Thanks

    • Hi!
      Write what is the second formula. Both of these formulas must refer to the same cells. Otherwise, their association does not make sense.

      • Yes there are 2 columns Column A and Column B.

        For column A formula is;
        "=IF((A10),"Recd","0")"

        I want to merge the formula and track the value at single cell.

        please advise if there is any other formula bring the result.

        • For Column B formula is;
          "=IF((L10>0),"Recd","0")"

        • Hi!
          I’m not sure I got you right since the description you provided is not entirely clear. However, it seems to me that the formula below will work for you:

          =IF(OR(A10>0,L10>0),"Recd","0")

  16. Hi there, I am trying to match criteria between two columns. In the event that they do match, I want their number values in a third column to be summed for the specific rows only where they are matching in the first two columns.

    i.e. A5 "John" matches B118 "John" therefor i want to sum C5 "450" & C118 "550", giving me a total of 1000 in both D5 & D118.

    I would then also like to add an extra condition where it only needs to match the criteria in an additional columns.

    i.e. let say column E. Both E5 & E118 must be "xyz", else column D will not sum D5 & D118.

    Thanks

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

      =(IFERROR(INDEX($C$1:$C$100,MATCH(A1,$B$1:$B$100,0)),0)+C1) * ISNUMBER(MATCH(A1,$B$1:$B$100,0)) + (IFERROR(INDEX($C$1:$C$100,MATCH(B1,$A$1:$A$100,0)),0)+C1) * (ISNUMBER(MATCH(B1,$A$1:$A$100,0)))

      You can read more about searching values using INDEX+MATCH in this article.

  17. Which formula should I use when issuing rates to water consumers by using different rates?

  18. Dear Sir,

    I need your help on following formula,

    IF A1=A and If B1>26 then rate should be 400, but if A1=B and if B1>26 then rate should be 380
    IF A2=A and if B1>22 then rate should be 380, but if A2=B and if B2>22 then rate should be 360

    please share which formula to do this kind of work with multiple conditions

    Nageshwar

    • Hello!
      Your terms don't seem to be entirely correct. Can be done at the same time: IF A1=A and If B1>26 then 400 and IF A2=A and if B1>22 then 380.
      All the necessary information to write the formula is in the article above.

  19. =IF(AND(G71="*(G11)*",BC71="ABM*"),BB71,"x")
    =IF(AND(G71="*(G11)*",BC71="ABM*"),"Please schedule interview","x")

    I thought I understood your instructions, but when I tried it... waaaaa
    Column G contains responses on level applying for while column BC contains the specific preferred strand for senior high school level. So that if column G says 'Grade Eleven (G11)' and column BC says 'ABM - Accountancy, Business, and Management' then the text in the BB cell should appear or in another cell I tried making it the sentence appear, "Please schedule interview"

  20. Hi there!
    Looks for assistance with this:
    IF 0.01to 1.00 then value +1
    If 1.01 to 2.99 then value /0.5
    If 3 to 999.99 then value /0.6
    If greater than 1000 then value /0.65

    I made this, but its not quite right.....

    =IF(AND(E10>=0, E101.01, E13.00, E101000.00, E10<1000000.00), E10/0.65, ""))))
    Thanks!!

    • IF(AND(E10>=0, E101.00, E10<2.99), E10/0,5 IF(AND( E10 1000.00), E10/0.6, IF (AND(E10<1000.00, E10<1000000.00), E10/0.65, ""))))

    • Hello!
      Please use the formula below:

      =IF(E10 > 1000,E10/0.65, IF(E10 > 3,E10/0.6, IF(E10 > 1.01,E10/0.5,IF(E10 > 0.01,E10+1,""))))

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)