Excel 2007: Check Multiple Conditions With Nested IF Functions

Written by:  • Edited by: Bill Fulks
Updated Aug 10, 2011
• Related Guides: Microsoft | Excel | Spreadsheet

With the 2007 version of Microsoft Excel, nested IF functions became a lot more powerful. We’ll explain more about this type of function and give a specific case when one can be used when assigning letter grades.

Nested IF Functions

Sample Digram for a Nested IF Function
click to enlarge
At first glance, the format of a basic IF function in Excel may lead some users to believe that the function can only be employed in times when there are just two choices to be made such as in the example we gave in Part 1 of this series. However, it is possible to use IF statements when there are more than two cases if the functions are nested correctly.

A nested IF function is a statement that contains at least one IF function inside another. That is, a nested IF function contains another IF statement as one (or both) of the true/false values. In this manner, the original IF function checks for a condition and, depending on the result of that check, it may go on to check another condition. The diagram to the left gives a basic representation of how this process works. (Click the image for a larger view.)

A basic IF function is of the form below.

=IF(condition, value if true, value if false)

A more concrete example that we created in Part 1 of this series is the function IF(B2>=70,"PASS","FAIL").

On the other hand, nested IF functions can take on a variety of different appearances, depending on how complex the nesting sequence is. One example is shown below.

=IF(condition1, value1 if true, IF(condition2, value2 if true, value2 if false))

Extending the Example

Let’s take a look at the example we gave in Part 1 again. Suppose now, that instead of wanting to just assign a grade of Pass or Fail, that the instructor wants to assign the letter grades A, B, C, or F based on the following rules.

  • If the percentage correct is 90 or higher, the student will receive an A.
  • If the percentage is 80 or higher but less than 90, the student will receive a B.
  • If the percentage is 70 or higher but less than 80, the student will receive a C.
  • All other students will receive an F.

We’ll add a new column to the spreadsheet used in Part 1 of this series to account for the letter grade.

Letter Grade Column
click to enlarge

Since we’re using a nested IF function, we need to approach this a little different than we did in Part 1. Instead of selecting the function tool from the Formula tab, we’ll just select the first empty cell in the Letter Grade column and type in the following formula.

=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C","F")))

Creating Formula
click to enlarge

Then, we’ll copy the formula and paste it into the other cells of the column.

After Pasting Formula
click to enlarge

Limitations of Nested IF Functions

While previous versions of Excel limited users to no more than seven levels of nested IF functions, Excel 2007 supports up to 64 nested functions. Does that mean you want to use an IF function for situations when you have dozens of conditions? You could, but I wouldn’t recommend it. There are better, more efficient functions to use in situations like this. We’ll be covering them later in this series.

References


Comments

Showing all 12 comments
 
Jamie M Feb 14, 2012 8:37 PM
RE: Excel 2007: Check Multiple Conditions With Nested IF Functions
This works perfectly if you are looking at one number. What if you were looking at more than one number (in different cells) treating them as a group to see if the group passed or failed?
Michele McDonough Sep 9, 2011 11:31 AM
Using formulas within the IF function
Yes, that should work, but the formulation of the statement will depend a little on the condition you're checking in cell A. One sample statement would be =IF(A1=TRUE, cell1 - cell2, cell1 + cell2)
Kat Sep 9, 2011 9:55 AM
Using formulars WITHIN the IF function
I have a question regarding the usage of formulars within the IF function.
What I want is: IF the value in a cell A (=true), I want excel to calculate cell 1 - cell 2. If the logical test is false, I want excel to calculate cell 1 + cell 2.
Is that possible?
Michele McDonough Apr 28, 2011 4:05 PM
RE: Nested IF statements
Could there be something else about the formula that is giving the limitation? What type of error are you receiving?
John J Moore Apr 28, 2011 10:18 AM
Excel Nested If Statements
I am using 2007 Excel and still cannot get more than 7 IF statements nested. Is there anything special that I should be doing to have more nested IF statements. I need 25, and it's really not that complicated.
Michele McDonough Jan 21, 2011 5:20 AM
RE: Excel 2007: Check Multiple Conditions With Nested IF Functions
That is a valid nested IF function - so, if it is not working as expected, there is probably some other error. Did you mean to switch from < to > when going from the second to the third IF?
MANJULA U Jan 21, 2011 5:04 AM
RE: Excel 2007: Check Multiple Conditions With Nested IF Functions
=IF(B2<50,"P",IF(C2<50,"P",IF(D2>50,"P",IF(E2>50,"P","F"))))

WHAT IS THE PROBLEM IN THIS
Joseph Zamer Nov 10, 2010 7:20 AM
Looking for that many years ago
Really helpful, thank you.
SUNDAY JOHN Aug 23, 2010 5:09 AM
I WANT TO NOMORE ABOUT THIS EXCEL
PLS I CAN I DO IT
JimmyVarghese Apr 25, 2010 7:54 AM
Very Nice
Nice explanation!!!
Kiyas Aug 31, 2009 2:59 AM
RE: Excel 2007: Check Multiple Conditions With Nested IF Functions
Beautiful explaining & very useful
Subhankar Jul 31, 2009 1:22 AM
RE: Excel 2007: Check Multiple Conditions With Nested IF Functions
very good
 
blog comments powered by Disqus
Email to a friend