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. Hi, I am new to excel formulas. Can you help me with this
    if a date listed in a column of another page equals the same date of the current page, then a specific column/row total from the other page equals total on current page designated column/row.
    thanks

    • hmm, guess I don't even get a reply...? thanks

      • Hello!
        Your description of the problem is not very clear. However, a formula like this may be suitable for you.

        =IF(A1=Sheet1!A1,SUM(Sheet1!B:B),0)

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

  2. I have days in one column line 1, 2, 5, 6, 1, 2, 6 5,3,2,0,4,6,7,4,1,3,2
    I need the result like if the days are between 1 to 3, then the next column should update as 1 to 3 Days.

    1 next to that cell should show 1 to 3 Days
    2 next to that cell should show 1 to 3 Days
    3 next to that cell should show 1 to 3 Days
    4 next to that cell should show 4 to 6 Days

    • Hi,
      had to try. I have a suggestion for this. It is not pretty, someone for sure will find more elegant solution, but it should work.

      For me in this forum the larger than and smaller than symbols doesn't seem to show at all so I'll use capital L for larger than symbol and capital S for smaller than symbol. Let's assume that the list of days is located to A-column and it starts from line 2. I wrote this formula on cell B2.

      =If(A2L6, "error, too high date", IF(A2L=, "4 to 6 Days", IF(A2=0, "error too low", IF(A2S=3, "1 to 3 Days", "unknown error")

      Hopefully this helps :)
      Antti

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

      =IF(A1<4,"1 to 3 Days",IF(A1<6,"4 to 6 Days","7 Days" ))

      I hope this will help

  3. Hi,
    I think this answer should be exctremely easy, but I just cant find the correct answer.

    I have column with differend numbers (1-18 representing differend areas and I have named the column "Area") and I like to use the Area column to let my formula count all the data from that spesific line. Formula looks something like this:

    =AVERAGEIFS(E3:E1500, E3:E1500,"0", Area, 1)
    (there might be errors in my typing, because Finnish version has a bit differend style to write the formula).

    I would just like to be able to choose with the same time with the same formula multiple area numbers. Like:
    =AVERAGEIFS(E3:E1500, E3:E1500,"0", Area, 1 or 3 or 8)

    Thank you for your help.

    • I don't know why it removed my typing for with the 0. The formula checking that the counted number is differend than 0 (with Finnish Excel it is " 0")

      • Ok, larger than and smaller than wont show up :)

  4. Hello - I need some help with IF/AND functions or maybe it is another formula entirely. I have two columns of data with numbers separating subsets. I am trying to assign the number value to each subset. So there could be 10 data points in one subset, and 20 in another but I want the same identifier for all of the datasets in that subset. This formula simply found that what I'm looking for is a number, but how do I return the value of that number? =IF(ISTEXT(B4),"Text",IF(ISNUMBER(B4),"Number",IF(ISBLANK(B1),"Blank",""))) Thank you!

  5. hey everyone, need help with a formula with a different outcome for 4 different Conditions;
    IF A1=R output should be 25
    IF A1=RR output should be 37.5
    IF A1=G output Should be 50
    IF A1=GG output Should be 93
    please anyone???

    • Hi,
      Try this.
      =IF(A1="R", 25, IF(A1="RR", 37.5, IF(A1="G, 50, IF(A1="GG", 93, "Wrong input"))))
      Sincerely,
      Antti

  6. Hi!
    I need to highlight 20 columns, if 3 of the columns have yes then its good if not I need it flagged. How can I accomplish this?

  7. Hi, I have a pretty complex (for me) formula that i want to write.
    If a<b, then a*c
    If d e, AND if f="x", then a*g; BUT if f="y", then a*h; BUT if f="z", then a*i
    If j k, AND if f="x", then a*l; BUT if f="y", then a*m; BUT if f="z", then a*n
    If o p, AND if f="x", then a*q; BUT if f="y", then a*r; BUT if f="z", then a*s
    If a>p, AND if f="x", then a*t; BUT if f="y", then a*u; BUT if f="z", then a*v
    Can anyone please suggest a way how I can do this.

  8. Hi, I am using the IF with AND & OR functions. Within that though, I have a cell with a flavour name, which I want to assign a number. How do I do that, please?

    • Basically, I want to say "(C3)banana + (D3)1.0 = (E3)$40" or "(C3)banana + (D3)2.0 = (E3)$75"
      C3 being the flavour and D3 being the weight, while E3 has the function which gives the price for the stated flavour and weight.

  9. I am trying to work an amortization schedule that will be calculated base on Purchase date-Sale Date-Floor plan-Non Floor Plan Date and availability date.
    Column G Column H Column K Column M
    Date of Purchase Date of Sale Floor plan due date Loan End date
    Jun-17 Jun-20 Dec-19 Jul-20
    Jun-17 Available None May-22
    Jun-17 June-20 None May-22
    This is what i have so far and it is working great.
    =IFS($K$99=$H$99,0,P1>$M$99,0,P1=$K$99,$O$99,P1$H99,0,P1>$K$99,O100-P32,$K$99=$H$99,0,TRUE,0)
    But as soon as my Floor Plan end date has None, the formula doesn't work any more. I need to add a this condition to my formula IF(AND(AND(Month=G1,K1="None",h1="available",Loan amount,0)
    Any suggestions?

  10. Hello.
    I have a spreadsheet that is giving me an issue.
    This what I have and its returning the correct response except for 128:Up with 132: Down
    and it returns "FALSE" if AV5 is blank.
    =IF(AW$5>0,IF(AW132="Down",IF(AW128="Down","Yes",IF(AW128="Up",IF(AW132="Up","Yes","No"))),"Yes"))

    What I want it to do in cell AV134:
    If AV5 is blank then I want AV134 to also be blank.
    IF AV132 AV128 AV134
    Down Down Yes
    Down Up No
    Up Down No
    Up Up Yes
    Thank you for any clarification that you are able to provide.

  11. I need to write formula where if column A equals multiple value (e.g. 1, 2, 5 & 6) and column B is more than 7, then "Y" if not "N".
    I wrote the formula as "IF(AND(OR(A=1, A=2, A=5, A=6), (B>7), "Y", "N")
    i think it's wrong since there's no "Y" value at all.
    Thanks!

  12. D S.I 0-35 36-45 46-60 70+
    300000 300000 1778 2576 3651 6642
    300000 500000 2446 3451 4646 8283
    500000 500000 1523 1936 2480 4127
    500000 700000 1790 2240 2888 5167
    600000 600000 1398 1707 2310 4127
    600000 800000 1650 1993 2643 5006
    800000 800000 1387 1570 2230 4641
    800000 1000000 1655 1859 2576 5397
    1000000 1000000 1409 1560 2089 4641
    1000000 1500000 2052 2272 2982 6073
    1500000 1000000 1325 1449 1955 3471
    1500000 1500000 1968 2160 2848 4641
    1800000 1000000 1306 1437 1967 3029
    1800000 1200000 1563 1722 2325 3471
    2000000 1000000 1294 1432 1979 2795
    2000000 2000000 2506 2785 3682 4899
    2000000 3000000 3652 4076 5310 6936

    how to use if formula when i enter age, deductible and sum insured and automatically premium generated

  13. What kind of formula I need to obtain expiration date on courses that have different length of expiration i.e some expire in 7 days, some in 14 and others in 21 days. I only have their start date.

  14. Hello everyone,
    I hope you are well.
    I have a question, if somebody can help me out, I am struggling long time already.

    i have numbers from 0 to 360°. When i enter any numbers from 0 to 360, it should gave me the final answer as per below table. I did a formula that works but only for few numbers not all (=IF(AND(0H10), "0.5", "0")), so if am choosing numbers from 0 to 44, i have the answer 0.5 and more than 45 is answer 0,
    but now i came to a problem how to insert multiple IF and AND in one long formula. I tried but always something wrong.
    I would like to have in the empty cell with formula that is choosing automatically from the main table as per the insert number from 0 to 360°.

    N 000 0.5
    015 0.5
    030 0.5
    NE 045 0
    060 0
    075 0
    E 090 -1
    105 -1
    120 -1
    SE 135 -1.5
    150 -1.5
    165 -1.5
    S 180 0
    195 0
    210 0
    SW 225 -0.5
    240 -0.5
    255 -0.5
    W 270 0.5
    285 0.5
    300 0.5
    NW 315 0
    330 0
    345 0

    Thank you very much guys, much much appreciated. Have a great day all !!

  15. I have a list of mileage date captured over a month with numerous entries each day I need to extract the max and min mileage per day.
    please help with a formula

  16. I need help on a timecard formula. I'm brain-dead right now. If A + B + C > =40, "40" otherwise it should be the sum of A + B + C only. How do I do the "Otherwise" portion of this formula is the sum is less than forty hours?

  17. Hi, I am hoping there is a way to do this. It seems basic, but I am new to these Excel IF statements. I have two columns (F & G) that I need to have high, medium and low values in. And then I want to have a priority level column where I assign a priority level of either high, medium or low based off of the combination of the entries in columns F & G.
    Here is my scoring logic below. Wondering if this can be put into an IF statement and how to enter it?

    If 1 value is high and the other is high then the result is high
    If 1 value is high and the other is medium then the result is high
    If 1 value is high and the other is low then the result is medium
    If 1 value is medium and the other is medium then the result is medium
    If 1 value is medium and the other is low then the result is medium
    If 1 value is low and the other is low then the result is low

  18. Please send me correct formula

    BELOW 1 THEN 0
    FROM 1 TO 250000 THEN ACTUAL FIGURE
    FROM 250000 ABOVE THEN 250000

    • Hi,
      Again, I don't know why, but for me this message board wont show my larger (L) than and smaller (S) than symbols. I will use capital L and capital S for them.

      Let's say that your number is on A column and starting from A1.

      =IF(A1 L= 250000, 250000, IF(A1 S 1, 0, A1))

      Hopefully this helps.
      Sincerely,
      Antti

  19. This is scenario I am struggling to create a multiple formula:
    1.If AA2 = Y and AB2 = Y results should be "Accrue income"
    2 If AA2 = N and AB2 = N results should be "not Accrue Income" and
    3. If AA2 = Y and AB2 = N results should be " Not Accrue Income and vice versa.
    Thank you for your help

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

      =IF(AND(A2="Y",B2="Y"),"Accrue income",IF(AND(A2="N",B2="not Accrue income"),"N",IF(AND(A2="Y",B2="N"),"Not Accrue income and")))

      I hope my advice will help you solve your task.

      • Hello.
        I have a spreadsheet that is giving me an issue.
        This what I have and its returning the correct response except for 128:Up with 132: Down
        and it returns "FALSE" if AV5 is blank.
        =IF(AW$5>0,IF(AW132="Down",IF(AW128="Down","Yes",IF(AW128="Up",IF(AW132="Up","Yes","No"))),"Yes"))

        What I want it to do in cell AV134:
        If AV5 is blank then I want AV134 to also be blank.
        IF AV132 AV128 AV134
        Down Down Yes
        Down Up No
        Up Down No
        Up Up Yes
        Thank you for any clarification that you are able to provide.

  20. Hi, Im trying to calculate the following,
    Rep 1 belongs to team 1
    Rep 2 belongs to team 2
    Rep 1 has an individual Count
    Team 1 has an average rate
    for Example:
    If rep 1 Count >=2 or the average rate for Team 1 >=3% then rep 1 will get 5 points, if the cell is blank then zero, if none of these is met then -2 points and same for team 2. this is what i have so far but is giving me an error on the formula:
    =IF(AND(C8="Team 1",$C$30>=3%),5,IF(AND(C8="Team 2",$C$29>=3%),5, IF(D8>=2),5, IF(OR(D8="-",d8=””)0, -2))))
    Hope this is clear, thank you in advance

    • Nevermind, i was able to figure it out, =IF(OR(AND(C9="Team1",$C$30>=3%),(D9>=2)),5,IF(OR(AND(C9="Team2",$C$29>=3%)),5,-2))
      Thanks anyways, you're examples really helped me.

      • =IF(D8="",0,IF(OR(AND(C8="Villains",$C$30>=3%),(D8>=2)),5,IF(OR(AND(C8="Heroes",$C$29>=3%)),5,-2)))

    • Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail?
      What does "If rep 1 Count >=2"? Write an example of the source data and the result you want to get.
      It’ll help me understand it better and find a solution for you. Thank you.

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 :)