Skip to main content

How to Do Nested IF Statements in Excel

I am an accountant and love to work in Excel. My wife and I have our own custom invitation and photography business.

Learning how to use nested IF statements in Excel will make your life easier and you will become much more efficient in Excel. Nested IF statements are a powerful way to perform complex calculations in a single cell. As an accountant, I use nested IF statements every day at work and I do not know what I would do without them.

What Is a Nested IF Statement?

You may be thinking what exactly is a nested IF statement? A nested IF statement contains at least one IF statement inside of another as part of the argument. I think that the most nested IF statements that I have used in a formula are eleven when I was trying to control a year-to-date sales formula. You can also use other nested functions inside of an IF statement such as OR, AND, and NOT.

Nested IF Statements in Excel


Think of nested IF statements this way: If a condition is true, then enter this value, if it is not true, check to see if it meets the next condition. Is that condition true? If so, enter this value, otherwise, if it is false, enter this value. Nested IF statements may look complicated and seem hard to follow, but once you understand what Excel is looking for, they are actually quite simple to create. The picture above shows in detail what Excel requires for a formula with one nested IF statement. Let us take a look at the individual requirements in more detail.

Logical Test

The logical test is the value or expression that you want to test to see if it is true or false. You can use any calculation operator (=, >, <, <>, etc.) that you want. A great example would be B36=10. Excel will then look in cell B36 to see if it does equal 10 or not. This is a required field.

Value if True

The value if true parameter is simply the value that the formula will display if the Logical Test comes back as true. If this argument is left blank, then Excel will return a zero if the formula is true. The Value if True can be a number, text, formula, cell reference, or it can return a blank cell by using "".

Nested IF Statement

A nested IF statement will begin again with the Logical Test followed by the Value if True and repeated as many times as needed up to a total of 64 if you are using Excel 2007 or newer. Older versions of Excel limited you to seven times.

Value if False

The Value if False parameter is the value or expression that the formula will display if the Logical Test comes back as false. If this argument is left blank, then Excel will return the logical value of false. The Value if False can be a number, text, formula, cell reference, or it can return a blank cell by using "".

Example of Using Nested IF Statements in Excel

Now that we know what Excel is looking for, let us walk through a step-by-step example. I set up a spreadsheet that has three high-level income statements on it, one for actual results, one for budgeted results, and the third one for an actual versus budget income statement, which will be controlled by a drop down box that selects the current month in cell B3. Below is a picture of what the spreadsheet looks like.


Normally, if I was doing this for work, each income statement would be on its own tab. I placed everything on one tab to make the explanation of this example clearer.

Current Month Actual Income Statement

Pulling only the current month information is much quicker and easier than the year to date data. Click in cell B23 and enter the following formula.


I know that is a lot to digest all at once. Let us break it down into understandable chucks.


The first part of the formula is the Logical Test and it looks up the contents of cell B3 to see if they equal January. There are two other things that I want to mention here. First, the $ on each side of the cell reference serve to anchor it so that no matter where this formula is copied and pasted, it will always point to cell B3. The second thing is that whenever you are looking for a text value in Excel, you have to enclose it in quotation marks.


The next part of the formula is the Value if True and says that if cell B3 equals January, then return cell B8, which is the actual sales amount for January. Notice the $ to the left of B8, it is there to hold the column reference only. It will allow the row reference to change.


The rest of the formula repeats itself. Notice how the Logical Test changes each time to test for a different month. Also, the Value if True changes a column each month to pick up the correct income statement amount.


Finally, we get to the Value if False argument. I prefer to add an error message just in case the value in cell B3 becomes something that it should not be. You could end with December being the Value if False if you wanted too. Also, it is important that you add the exact amount of closing parenthesizes as you have opening ones. Hit the enter key and you should now see this.


Copy the formula in B23 and paste it into cells B24 and B25. Notice that the cell B26 is now equal to cell D11.


Current Month Budgeted Income Statement

Next we need to bring in the budgeted income statement. There are two ways to do this. Either we could enter another lengthy formula from scratch or we could use a little trick that I learned. Normally, I would have each of these income statements on separate tabs, perfectly lined up with each other. Then all we would have to do is copy the formula over since we anchored the column headings and it would correctly pull the right month. However, since everything is on one tab, the budget data does not line up with the same row references. Thankfully, I have another trick up my sleeve. Copy cell B23 and paste it into C23. All of the column references should still be the same (start with B in the first Logical Test and end with M in the last one). See the picture below:


Video Example of Using Nested IF Statements to Assign Letter Grades

Highlight cells C23 through D23. Hit Cntrl + H, which will bring up a Find and Replace dialogue box. In the "Find what:" box, enter "8". In the "Replace with:" box, enter 15. We want to Excel to find all of the references to 8 in the formula and replace them with 15. Basically what this is doing is changing the row that the Value if True argument is going to return if the Logical Test returns as true. It is important that more than one cell is highlighted, otherwise, Excel will replace all references to 8 on the spreadsheet. Copy the cell C23 down and paste it into cells C24 and C25. Your actual versus budget income statement should now look like this.


The actual versus budget income statement can also be setup to show the year to date balances of each. The only difference would be that each month in the Value if True argument, you add up each month to that point. The formula would look like this:



For anyone who works with Excel on a regular basis, I would highly recommend that they learn how to use nested IF statements. They are an invaluable tool for data manipulation and for compiling reports. I can say from personal experience that they have made me much more efficient in Excel.

This article is accurate and true to the best of the author’s knowledge. Content is for informational or entertainment purposes only and does not substitute for personal counsel or professional advice in business, financial, legal, or technical matters.

© 2014 Eric Cramer


Larry Rankin from Oklahoma on June 10, 2015:

When it comes to Excel, I can use all the help I can get.

Great Hub!

ubrish ali from Pakistan(Asia) on November 12, 2014:

So much information about excel.thanks for sharing