+ Reply to Thread
Results 1 to 13 of 13

nested if

Hybrid View

  1. #1
    Registered User
    Join Date
    05-07-2009
    Location
    leeds, england
    MS-Off Ver
    Excel 2007
    Posts
    29

    nested if

    Hello all,

    I know there is a really easy solution to this but I don't seem to have the intelligence required to resolve it!

    In cell A1 I want a function that says:

    If the value is less then 5'000 = 50
    If the value is less then 10'000 and larger then or equal to 5'000 = 100
    If the value is less then 20'000 and larger then or equal to 10'000 = 150
    If the value is less then 30'000 and larger then or equal to 20'000 =250
    Greater then 30'000 =400

    Many thanks

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: nested if

    Hi,

    I'm assuming you mean that the value you want to test is in A1. So one way is

    =IF(A1<5000,50,IF(A1<10000,100,IF(A1<20000,150,IF(A1<30000,250,400))))
    another option would be to use a VLOOKUP table.

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: nested if

    To demo the lookup based approach Richard mentions (given it's scalable)

    =IF(N(A1),LOOKUP(N(A1),{-9.99E+307,5000,10000,20000,30000},{50,100,150,250,400}),"")

  4. #4
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: nested if

    @DonkeyOte. Hi Don, good morning.

    If you dont mind taking the time to explain. I don't understand the use of the N value here - i have just read that this function converts a value to a number, but isn't A1 going to be a number anyway. I am still working out the translation into english of the rest of the formula.... i'm sorry to bother you with minutiae.... cheers Don. Hope you are keeping well

    =IF(N(A1),LOOKUP(N(A1),{-9.99E+307,5000,10000,20000,30000},{50,100,150,250,400}),"")
    Blake 7

    If your question has been answered, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    If any member's response has helped to solve your problem, please consider using the scales icon on the top right of their post to show your appreciation.

    http://failblog.org/

  5. #5
    Registered User
    Join Date
    05-07-2009
    Location
    leeds, england
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: nested if

    Hello,

    Can anyone tell me what is wrong with my formula?:

    IF((F50:F109)<5000,50,IF((F50:F109)<10000,100,IF((F50:F109)<20000,150,IF((F50:F109)<30000,250,400))))

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: nested if

    this is an array formula and needs to be confirmed with Ctrl-Shift-Enter

  7. #7
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Re: nested if

    your formula should be:
    =IF(SUM(F50:F109)<5000,50,IF(SUM(F50:F109)<10000,100,IF(SUM(F50:F109)<20000,150,IF(SUM(F50:F109)<30000,250,400))))
    --
    Regards
    PD

    ----- Don't Forget -----

    1. Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks

    2. Thank those who have helped you by Clicking the scales above each post.

    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  8. #8
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: nested if

    pr4,

    why sum? Executed as an array formula, each cell gets evaluated individually. Quite a difference.

  9. #9
    Forum Contributor pr4t3ek's Avatar
    Join Date
    10-13-2008
    Location
    Melbourne, Australia
    MS-Off Ver
    2003 & 2007, 2010
    Posts
    483

    Re: nested if

    apologies, yes you are correct. i didn't exactly read his5r's question. array is correct. please ignore my formula

  10. #10
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: nested if

    Hello Blake 7

    =if(n(a1), tests if A1 is a number. If it is text, the rest of the formula will not be executed and an error message caused by a text value will be avoided.

    The second N(A1) is not really required, since it's already established that A1 is a number.

    If A1 is a number stored as text, n(a1) will result in "false" and the rest of the formula will not be executed.

    If you'd want the formula to execute with numbers stored as text as well as with real numbers, you'd need something like

    =IF(ISNUMBER(A1+0),LOOKUP(A1+0,{-9.99E+307,5000,10000,20000,30000},{50,100,150,250,400}),"")
    Last edited by teylyn; 11-04-2010 at 05:08 AM.

  11. #11
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: nested if

    Thanks Teylyn for your explanation. Kind of you to take the time. I understand now how the N has been used aswell as the difference between N and isnumber so thanks alot.

    Hope all well with you.
    Last edited by Blake 7; 11-04-2010 at 05:27 AM. Reason: took out a sentence as i now know the answer!

  12. #12
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: nested if

    Blake, the {} are used to define an array.

    {1,2,3} is an array of three cells in a column, like
    1
    2
    3


    {1;2;3} is an array of three cells in a row, like

    1 | 2 | 3

    (where the | sign is the cell border )

    and

    {111,222,333;444,555,666;777,888,999} is an array of 9 cells arranged in 3 columns and 3 rows.

  13. #13
    Valued Forum Contributor Blake 7's Avatar
    Join Date
    10-01-2010
    Location
    Bogota, Colombia
    MS-Off Ver
    Excel 2010 64 bit and Excel 2007,
    Posts
    1,377

    Re: nested if

    Thanks so much. This is wunderschon! forgive me, I don't have the umlaut....

    Theres so much to learnnnnnn!!! argghhhhhhhhhh

    Have a good day

+ 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.6.0 RC 1