+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Nested If statement Help

  1. #1
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Nested If statement Help

    Hi everyone,

    I am a beginner with excel programming, so if there is a better way do what I am attempting please tell me. I am using nested if statements to determine where a value is in a range of different values. Everything is working perfectly when a value is entered into C2, however, when C2 is left blank and no value is entered, it is returning a value of 20. I cannot understand why. I would like for it to either remain blank, or return a value of 0.

    =IF(AND(D2>0.05,D2<0.0999),"1",IF(AND(D2>0.1,D2<0.1499),"2",IF(AND(D2>0.15,D2<0.1999),"5",IF(AND(D2> 0.2,D2<0.2499),"9",IF(AND(D2>0.25,D2<0.2999),"14",IF(D2>0.2999,"20",IF(D2<0,"-2","0")))))))

    Austin
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,214

    Re: Nested If statement Help

    don't use qutes around numbers "1"
    Attached Files Attached Files
    "Relax. What is mind? No matter. What is matter? Never mind!"

  3. #3
    Valued Forum Contributor
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    380

    Re: Nested If statement Help

    Works OK on my system, but try this on yours...

    =IF(D2>0.2999,20,IF(D2>0.2499,9,IF(D2>0.1999,5,IF(D2>0.1499,2,IF(D2>0.0999,1,0)))))

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,214

    Re: Nested If statement Help

    dangelor, your solution will work.
    However, if you won't use LOOKUP function as I showed, my advice is to rather use >= approach

    =IF(D2>=0.3,20,IF(D2>=0.25,9,IF(D2>=0.2,5,IF(D2>=0.15,2,IF(D2>=0.1,1,0)))))

    Also, you missing -2 result for negative numbers (as I see it in original example)
    "Relax. What is mind? No matter. What is matter? Never mind!"

  5. #5
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    I have tried each of the above suggestions. they all return 20 if C2is left
    blank... any other assistance would be appreciated.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,214

    Re: Nested If statement Help

    Did you try solution I've gave you in post 2?
    "Relax. What is mind? No matter. What is matter? Never mind!"

  7. #7
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    Yes i remove all quotes around the numbers. i also tried the >= solution offered. all have the same result where 20 is returned if c2 is left blank.

    could someone provide a link to a lookup tutorial that i couldapply here. i understand how it works but cannot figure out how to get it to seach a range of numbers

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,214

    Re: Nested If statement Help

    I don0t know where you looking since it return 0. Post number 2 (not my second post)....

    http://www.excelforum.com/excel-prog...=1#post2672386
    "Relax. What is mind? No matter. What is matter? Never mind!"

  9. #9
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    When i take out the quotes and do not put a value into C2 (on the spreadsheet i attached) the value returned is 20. thanks for the link!

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,214

    Re: Nested If statement Help

    well, you've sad: I would like for it to either remain blank, or return a value of 0.

    If you want blank, use one more IF statement (and this works generaly):

    =IF(A1="", "", formula)
    "Relax. What is mind? No matter. What is matter? Never mind!"

  11. #11
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    I already have 7 if statements. excel will not allow any more.

  12. #12
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    Could you give me an example of how to implement the lookup function for this problem..

    that may ne the best route seeing as i need more if statements and they arnt allowed.

  13. #13
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    Wow im dumb...youposted a solved spreddsheet. thank you it works perfectly

  14. #14
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    6,214

    Re: Nested If statement Help

    This is 13th post already and in half of them I refer to 2nd post.
    Please, look attachemnt I've uploaded there and try to implement solution I've posted there. If it doesn't work explain what's not working.
    "Relax. What is mind? No matter. What is matter? Never mind!"

  15. #15
    Registered User
    Join Date
    12-30-2011
    Location
    Williamsburg Va
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Nested If statement Help

    Sorry im just new to these forums and did not realise that a reply could post an atachment. its my fault. thank you so much for your help. im sorry to have wasted your time. yiur solution works perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0