Excel nested IF statement - multiple conditions in a single formula

The tutorial explains how to use multiple IF in Excel and provides a couple of nested If formula examples for most common tasks.

If someone asks you what Excel function you use most often, what would your answer be? In most cases, it's the Excel IF function. A regular If formula that tests a single condition is very straightforward and easy to write. But what if your data requires more elaborate logical tests with multiple conditions? In this case, you can include several IF functions in one formula, and these multiple If statements are called Excel Nested IF. The biggest advantage of the nested If statement is that it allows you to check more than one condition and return different values depending on the results of those checks, all in a single formula.

In modern versions of Excel 2016, Excel 2013, Excel 2010 and Excel 2007, you can nest up to 64 IF functions in one formula. In Excel 2003 and lower, up to 7 nested IF functions can be used.

Further on in this tutorial, you will find a couple of Excel nested If examples along with the detailed explanation of their syntax and logic.

Example 1. Classic nested IF formula

Here's a typical example of Excel If with multiple conditions. Supposing you have a list of students in column A and their exam scores in column B, and you want to classify the scores with the following conditions:

  • Excellent: Over 249
  • Good: between 249 and 200, inclusive
  • Satisfactory: between 199 and 150, inclusive
  • Poor: Under 150

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

=IF(B2>249, "Excellent", IF(B2>=200, "Good", IF(B2>150, "Satisfactory", "Poor")))

And works exactly as it should:

Classic nested IF formula

Understanding Excel nested IF logic

I've heard some people say that Excel multiple If is driving them crazy :) Try looking at it at a different angle:

Nested If formula logic

What the formula actually tells Excel to do is to evaluate the logical_test of the first IF function and, if the condition is met, return the value supplied in the  value_if_true argument. If the condition of the 1st If function is not met, then test the 2nd If statement, and so on.

IF(check if B2>=249, if true - return "Excellent", or else 
IF(check if B2>=200, if true - return "Good", or else
IF(check if B2>150, if true - return "Satisfactory", if false -
return
 "Poor")))

Example 2. Multiple If with arithmetic calculations

Here's another typical task: the unit price varies depending on the specified quantity, and your goal is to write a formula that calculates the total price for any amount of items input in a specific cell. In other words, your formula needs to check multiple conditions and perform different calculations depending on what amount range the specified quantity falls in:

Unit Quantity Price per unit
1 to 10 $20
11 to 19 $18
20 to 49 $16
50 to 100 $13
Over 101 $12

This task can also be accomplished by using multiple IF functions. The logic is the same as in the above example, the only difference is that you multiply the specified quantity by the value returned by nested IFs (i.e. the corresponding price per unit).

Assuming the user enters the quantity in cell B8, the formula is as follows:

=B8*IF(B8>=101, 12, IF(B8>=50, 13, IF(B8>=20, 16, IF( B8>=11, 18, IF(B8>=1, 20, "")))))

And the result will look something similar to this:

Nested IF formula to perform different calculations on numbers within a certain range

As you understand, this example demonstrates only the general approach, and you can easily customize this nested If function depending on your particular task.

For example, instead of "hard-coding" the prices in the formula, you can reference the cells containing those values (cells B2 to B6). This will enable your users to edit the source data without having to update the formula:

=B8*IF(B8>=101,B6, IF(B8>=50, B5, IF(B8>=20, B4, IF( B8>=11, B3, IF(B8>=1, B2, "")))))

An improved formula with multiple IF functions

Or, you may want to include an additional IF function(s) that fixes an upper, lower or both bounds of the amount range. When the quantity is outside the range, the formula will display an "out of the range" message. For example:

=IF(OR(B8>200,B8<1), "Qty. out of range", B8*IF(B8>=101,12, IF(B8>=50, 13, IF(B8>=20, 16, IF( B8>=11, 18, IF(B8>=1, 20, ""))))))

Nested IF's formula with fixed bounds

The nested IF formulas described above work in all versions of Excel 2016 -2000. In Excel 2016 that is part of Office 365 subscriptions, you can use the IFS function for the same purpose.

Advanced Excel users that are familiar with array formulas, can use this formula that basically does the same thing as the nested IF function discussed above. Though the array formula is far more difficult to comprehend, let along to write, it has one indisputable advantage - you specify the range of cells containing your conditions rather than referencing each condition individually. This makes the formula more flexible, and if your users happen to change any of the existing conditions or add a new one, you will only have to update a single range reference in the formula.

Excel nested IF - tips and tricks

As you have just seen, there is no rocket science in using multiple IF in Excel. The following tips will help you improve your nested IF formulas and prevent common mistakes.

Nested IF limits

In Excel 2016 - 2007, you can nest up to 64 IF functions. In older versions of Excel 2003 and lower, up to 7 nested IF functions can be used. However, the fact that you can nest a lot of IFs in one formula doesn't mean you should. Please keep in mind that each additional level makes your formula more difficult to understand and troubleshoot. If your formula has too many nested levels, you may want to optimize it by using one of these alternatives.

The order of nested IF functions matters

The Excel nested IF function evaluates the logical tests in the order they appear in the formula, and as soon as one of the conditions evaluates to TRUE, the subsequent conditions are not tested. In other words, the formula stops after the first TRUE result.

Let's see how it works in practice. With B2 equal to 274, the nested IF formula below evaluates the first logical test (B2>249), and returns "Excellent" because this logical test is TRUE:

=IF(B2>249, "Excellent", IF(B2>=200, "Good", IF(B2>150, "Satisfactory", "Poor")))

Now, let's reverse the order of IF functions:

=IF(B2>150, "Satisfactory", IF(B2>200, "Good", IF(B2>249, "Excellent", "Poor")))

The formula tests the first condition, and because 274 is greater than 150, the result of this logical test is also TRUE. Consequently, the formula returns "Satisfactory" without testing other conditions.

You see, changing the order of IF functions changes the result:
The order of nested IF functions matters

Evaluate the formula logic

To watch the logical flow of your nested IF formula step-by-step, use the Evaluate Formula feature located on the Formula tab, in the Formula Auditing group. The underlined expression is the part currently under evaluation, and clicking the Evaluate button will show you all the steps in the evaluation process.

For example, the evaluation of the first logical test of the nested IF formula shown in the screenshot below will go as follows: B2>249; 274>249; TRUE; Excellent.
Watch the logical flow of your nested IF formula by using the Evaluate Formula feature.

Balance the parenthesis of nested IF functions

One of the main challenges with nested IFs in Excel is matching parenthesis pairs. If the parentheses do not match, your formula won't work. Luckily, Microsoft Excel provides a couple of features that can help you to balance the parentheses when editing a formula:

  • If you have more than one set of parentheses, the parenthesis pairs are shaded in different colors so that the opening parenthesis matches the closing one.
  • When you close a parenthesis, Excel briefly highlights the matching pair. The same bolding, or "flickering", effect is produced when you move through the formula by using the arrow keys.

Balance the parenthesis of nested IF functions

For more information, please see Match parenthesis pairs in Excel formulas.

Treat text and numbers differently

When building logical tests of your nested IF formulas, remember that text and numbers should be treated differently - always enclose text values in double quotes, but never put quotes around numbers:

Right: =IF(B2>249, "Excellent",…)

Wrong: =IF(B2>"249", "Excellent",…)

The logical test of the second formula will return FALSE even if the value in B2 is greater than 249. Why? Because 249 is a number and "249" is a numeric string, which are two different things.

Add spaces or line breaks to make nested IFs easier to read

When building a formula with multiple nested IF levels, you can make the formula's logic clearer by separating different IF functions with spaces or line breaks. Excel doesn't care about extra spacing in a formula, so you may not worry about mangling it.

To move a certain part of the formula to the next line, just click where you want to insert a line break, and press Alt + Enter. Then, expand the formula bar as much as needed and you will see that your nested IF formula has become much easier to understand.
Add line breaks to improve the readability of nested IFs.

Alternatives to nested IF in Excel

To get around the limit of seven nested IF functions in Excel 2003 and older versions and to make your formulas more compact and fast, consider using the following alternatives to nested Excel IF functions.

  1. To test multiple conditions and return different values based on the results of those tests, you can use the CHOOSE function instead of nested IFs.
  2. Build a reference table and a use VLOOKUP with approximate match as shown in this example: VLOOKUP instead of nested IF in Excel.
  3. Use IF with logical functions OR / AND, as demonstrated in the these examples.
  4. Use an array formula like shown in this example.
  5. Combine multiple IF statements by using the CONCATENATE function or the concatenate operator (&). A formula example can be found here.
  6. For experienced Excel users, the best alternative to using multiple nested IF functions might be creating a custom worksheet function using VBA.

This is how you use an If formula in Excel with multiple conditions. I thank you for reading and hope to see you on our blog next week.

Available downloads:

To have a closer look and probably reverse engineer the formulas, you are welcome to download the sample Nested If Excel worksheet.

You may also be interested in:

315 Responses to "Excel nested IF statement - multiple conditions in a single formula"

  1. BIRU says:

    =IF(H39>99,"5000",IF(H39>89,"4500", IF(H39>79,"4000", IF(H39>69,"3500",IF(H39>59,"3000", IF(H39>49,"2500",IF(H39>39,"2000", IF(H39>29,"1500", IF(H39>19,"1000", IF(H39>9,"500","NOT ELEGIBLE"))))))))))

  2. Nelson says:

    I have 2 sheets in excel, the first carrying the data and the second where the data will be placed. I am to compute the fuel consumption of the different types of equipment however there are types of equipment in the first sheet which has the same dates and have to be added together in a single cell in the 2nd sheet. Which formula should I use to compute it?

  3. Deb says:

    I need to do a formula that will look at a range of columns on a specific row and if a value then give data from that column with value row 2, where the column with value is different row.

  4. Michael says:

    Hi
    I'm hoping you can help me with a formula for this
    if A1:A2="","" if A1="" & A2 = X,"O" if A1:A2 = X,"X"

  5. Sheila says:

    Hi,
    Is there a way to write the formula below in Excel? The percentage ranges are column headings not individual cells.
    =if(B6 is greater than 5% but less than 10%,E4,if(B6(greater than 10% then F2,if(B6 is less than 5%, B3,error)))

  6. Larissa Castanheira says:

    Hi, I have two conditional parameters..
    The simple formula is: =IF(F19<=15; F18*F19*72; IF(F1930; F19*F18*72*0,91)))
    Where:
    F19 is number of days.
    F18 is number of cats.

    But I need another one when is more then 1 cat, so for each extra cat the value is $20, and not the same price of one. How do I work a formula with more then one condition parameter?

  7. SUVO ADHIKARY says:

    I have an excel sheet in which "C1" column is "MODEL" & "D1" column is "LANDING".
    Another side I have created a list of MODELS in "Q1" column & LANDING PRICE in "R1" column.
    I want a formula...that if I type a model number in column "C2" landing will automatically will put in column "D2"

    • SUVO ADHIKARY says:

      I have an excel sheet in which "C1" column is "MODEL" & "D1" column is "LANDING".
      Another side I have created a list of MODELS in "Q1" column & LANDING PRICE in "R1" column.
      I want a formula...that if I type a model number in column "C2" landing will automatically will put in column "D2"
      And If I type any model number in the column "C2" landing price automatically will come to the column number "D2"

  8. Andrew says:

    Any help would be appreciated, i want to look at a cell and if it meets the criteria of GMBH or INC INC then it looks up the cell reference otherwise returns N/A but cant' get it to work.

    =IF(D708="GMBH",IF(D708-"INC", VLOOKUP('2018 Margin Data'!A$1:A$65536,'Master Margin'!$A$4:$T$983,17,0),"N/A"))

  9. Ulfa says:

    Need help to select items from column A with respect to range of items available in D column using if function.
    =if(A:A=range excluded plants,"YES","NO")

    PLANT Excluded Plants
    1 1052
    2 1014
    3 1033
    4 1015
    5 1018
    6 1017
    7
    8
    9
    1014

  10. MelhemJ says:

    Hello, Im looking to insert a nested IF function but only on blank cells of a column. Any idea?
    I Know how to fill out blank spaces with a value, but not with a formula.
    Thanks in advance!

  11. Abukar says:

    I need TO USE IF CONTIONS WITH 15 CONTIONS HOW I CAN GET

  12. Abukar says:

    I need TO USE IF CONTIONS WITH 15 CONTIONS HOW I CAN GET WIHT TEXTS

  13. Tharmaraj Rajandran says:

    Hi, I would like to kindly request some assistance.

    Is there any formula that can select a few cells below a VLookup result if a certain condition is met? Example VLOOKUP result is cell D10 but if the amount in cell E10 is >1, then the Vlookup should pull the result in cell D15. Appreciate any advice. Thank you so much

  14. Carla Sadlier says:

    I have a spreadsheet calculating months of service to clients. They can have a start date, a suspended date, a restart date and an exit date. The service may have never been suspended so the suspended date and the restart date could be empty. There could be a suspended date and never restart so the exit would be the same as the suspended date. I am trying to calculate the total months of service to each client. How can I write an if/or statement to tell it to use start date then suspended date then restart date then exit date, but to ignore there is no suspended date, but to use start and suspend date if there is no restart date? This is what I have so far: =(DATEDIF(D2,E2,"D")+DATEDIF(F2,I2,"D"))/30

  15. Maria says:

    I am grading a test and some questions have multiple answers and the answers are two characters. How do I look up answer (NM) in cell A1 and (ND) in cell B1 to the answer key that had (NM) in cell M1 and (ND) in cell N1? In order to be correct, both answers (NM &ND) have to be provided and does not have to be in any order. An I do this with an If then statement?

  16. laurie says:

    need an if statement that uses if c2 starts with '00' rather than typing out long names

  17. anne shepard says:

    My result returns #VALUE! how do I get around that?
    =IF('ADPR -AWARDS KDG L J TRANSITION'!L10<19000,'ADPR -AWARDS KDG L J TRANSITION'!A10*'ADPR -AWARDS KDG L J TRANSITION'!F10,0),IF('Benef Ovr Grid'!E3,'ADPR -AWARDS KDG L J TRANSITION'!L10-19000,0)

  18. kamth says:

    I cant do thes if statement

    cash back
    example 1 amount 5000 70
    example 2 amount 6500 110

    from to of amount max to give
    1000– 3000 1% 30
    4,000 - 6000 2% 80
    6,000 - 10000 4% 240
    10,000 - 15000 7% 700
    15,000 - Open 12% 1800

  19. Jeremy says:

    Is it possible to abbreviate the formula when non-consecutive numbers are used? I have a sheet where I need to assign 12 department numbers to one of three groups, with a 4th group as a catch all for outliers. The department numbers are not sequential.

    So for instance can I say IF(B2=(211,224,266,267),"Group A",IF(B2=(286,216),"Group B",IF(B2=(210,268,288,270,218,225),"Group C","Group D")))) it doesn't work. Do I need to write out a really long formula with all possibilites? What would that look like?

  20. Tapash Roy says:

    condition 1 = Sum Insured
    condition 2 = Age Bracket
    Result = Premium
    How to input the formula?
    Premium given in excel sheet in different row according to age bracket

  21. Hamed says:

    Hi,
    I have the following formula that works fine:
    =SUM(IF(G4="Rad",4,IF(G4="Green",3,IF(G4="Blue",2,IF(G4="Yellow",1,Good))))/COUNTA(G4:J4))

    where
    Red = 4
    Green =3
    Blue = 2
    and Yellow 1
    are a selection from dropdown list to calculate a percentage based on the selection.
    I want to apply this formula for entire row.

    what I did is below:
    =SUM(IF(G4="Rad",4,IF(G4="Green",3,IF(G4="Blue",2,IF(G4="Yellow",1))))
    +(IF(H4="Rad",4,IF(H4="Green",3,IF(H4="Blue",2,IF(H4="Yellow",1))))
    +(IF(I4="Rad",4,IF(I4="Green",3,IF(I4="Blue",2,IF(I4="Yellow",1))))
    +(IF(J4="Rad",4,IF(J4="Green",3,IF(J4="Blue",2,IF(J4="Yellow",1))))/COUNTA(G4:J4))

    It will be hard if have 30 or 50 cells,

    so is there a way to do it by selecting the range instead and each cell manual

  22. Coen Leemans says:

    HI,
    I have a question, I want to do a calculation for Logistics (Port Storage charges) these amounts changes every few days. The Number of days in port I have however how to calculate the following in af formula?
    From day 1 until day 11 = USD 0,00 per day
    From day 12 until day 20 = USD. 2.00 per day
    From day 21 until day 40 = USD 9.00 per day
    From day 41 until day 70 = USD 25.00 per day
    Over 70 days = USD 42 per day

  23. Emma says:

    Hi,

    I have a query, the below works but I need it to cover two ranges B38@B57 and G38:G57 rather than just the individual cells in each case, but when I input that I get #VALUE!
    Can anyone advise?

    =IF(B38="","Available",IF(G38="","Off Sick",IF(B38="",G38="","Available2")))

    Many thanks

  24. Kym says:

    Hello,
    I am attempting to figure out a formula for accessing lieu and vacation time accumulated and taken.
    If an employee has used up all lieu and I need time taken to start drawing from vacation what would be the formula?
    E.g. Employee has 15 lieu hours and 30 vacation hours.
    They take 16 hours off.
    The time has to come off lieu first then pull from vacation.

  25. Varun says:

    Amazing !!!!
    Excellent !!!
    Great !!!

  26. Ravi Shanker says:

    Hey I need some help, is it possible to fetch the below data with formula.
    I have a length formula in column b which is returning various values from col A. 17,14,13
    In case of 17 i have two arguments to check simultaneously,
    1. check the 4th character if it is "-" (hyphen) then mid(5,10)
    2.check the 14th character if it is "-" (hyphen) then mid(4,10)
    in case of 14 i have 4 arguments to check simultaneously,
    1. look for 4 character to be "-"(hyphen), then need right(10)
    2. look for 4 character to be " "(space), then need right(10)
    3. look for 11 character to be "-"(hyphen), then left(10)
    4. look for 1 character to be "*"(star shift8), then right(10)
    in case of len 13 2 arguments
    1. look for 11 character to be "-"(hyphen), then left(10),
    2. right(10)
    Can all the above arguments can happen with 1 if function starting in column c
    Please help

  27. ark_angel says:

    =IF(H2>=$F$1;IF(H1="NED";"NE";IF(H1>=$F$1;"DA";));"NE")
    i need to add another IF- if it is "SUB" then "NE"
    (H1="NED";"NE";IF(H1>=$F$1;"DA";));"NE")-> this but with SUB, and it needs to fit in the formula on the top
    pleeeease

  28. Tyler Christiansen says:

    So I use to work for a company that I helped them out with replacing parts on their machines when it got within a certain date range. I did this using excel and its the only one that I did. I currently working on something similar where lets say there is an end date of 1-6-2020 and I need a formula that gives me a red flag when the actual date gets within 30 days of that June Date. I can't remember how the formula goes. could anyone give me a little bit of advice?

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!
60+ professional tools 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
Awesome!!!
Sheila Blanchard