You are here:

Excel/multiple if statement

Advertisement


Question
Hello,

Thanks doe the reply.  I have developed the formula a little further, however some of it works and some of it does not.

Works:  If value above 30, and if value between 20 and 29.  
Does not work if value between 10 and 19 and 0 and 9.

IF(D11>=30,4,IF(OR(D11>=20,D11<=29),"3",IF(OR(D11>=10,D11<=19),"2",IF(OR(D11>=0,D11<=9),1))))

Can you shed any light,

regards,

Imtiaz

-------------------------
Followup To
Question -
Hello,

Hope you can help,

I have this formula sitting in L10.

A10 - Refers to a cell where I would enter a colleague name.

IF(A10="","",)-  If the cell has a null value, return no value.


I now need to calcualte a target figure, based on a number in D10.

The following rules need to apply.

If in D10 the number is between 0 and 9, return a value of 1.

If in D10 the number is between 10 and 20, return a value of 2.

If in D10 the number is between 21 and 30, return a value of 3.

If in D10 the number is greater than 30, return a value of 4.

I have having trouble getting the multiple if statement to work.

Can you help.

Regards,

Imtiaz
Answer -
=IF(A10="","",IF(D10>30,4,IF(D10>20,3,IF(F10>10,2,IF(D10>=0,1)))))

Answer
Yes -- look again at the formula.
IF(D11>=30,4,IF(OR(D11>=20,D11<=29),"3",IF(OR(D11>=10,D11<=19),"2",IF(OR(D11>=0,D11<=9),1))))

Suppose D11 has 15 in it. Well, 15 IS <=29, so it satisfies the condition IF(OR(D11>=20,D11<=29), so it never goes any farther. ANY number will satisfy the condition OR(D11>=20,D11<=29). Yes, ANY number. -43, 819283, any.

You need AND, not OR:
IF(D11>=30,4,IF(AND(D11>=20,D11<=29),"3",IF(AND(D11>=10,D11<=19),"2",IF(AND(D11>=0,D11<=9),1))))

But I think my solution is easier, shorter, and works!

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


Bob Umlas

Expertise

I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...)

Experience

Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Publications
Excellence, The Expert, Microsoft

Awards and Honors
MVP
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

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