You are here:

Excel/Looping IF logical tests

Advertisement


Question
Hello,
I can write a logical test to say if cell A3 = nothing then use value in cell A2 however I would like to loop this argument saying if A2 also = nothing then return the value in A1 and so on and so on... however I am struggling to find where I insert this argument.

Can you help?

Answer
Hi Dan,

When you link multiple IF's Excel calls it "nesting" IF's. With Excel 2003 and previous versions you can only "nest" 7 If's. With Excel 2007 you can nest up to 64 IF's. The one thing you have to keep in mind is that the multiple IF's will be evaluated from Left to Right. The first IF that meets the criteria will be returned. So for you example your nested IF statement would look something like this.

=IF(A7="",A6,IF(A6="",A5,IF(A5="",A4,IF(A4="",A3,IF(A4="",A3,IF(A3="",A2,A1))))))

Notice how each IF starts with a open parenthesis such as =IF(A7 but all the closing parenthesis are at the end of the formula.

The following website offers a good explanation of multiple IF's.

http://www.officearticles.com/excel/if_statements_in_formulas_in_microsoft_excel...

Thank You,

Ken
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

All Answers

Answers by Expert:


Ask Experts

Volunteer


Ken Marron

Expertise

I enjoy answering even the simplest questions. But I feel I am prepared to answer some advanced questions too. I have written complex formulas needed for my own company. I have some limited knowledge of VBA.

Experience

I have worked with Excel for 18 years. I have developed some of the applications necessary for a construction company. Including a labor estimating program that we use.

©2009 About.com, a part of The New York Times Company. All rights reserved.