+ Reply to Thread
Results 1 to 6 of 6

IF - returning a value between a range of numbers

  1. #1
    Registered User
    Join Date
    09-29-2008
    Location
    UK
    Posts
    2

    IF - returning a value between a range of numbers

    Hi,
    Its probably already been answered here, but I need to return a value if a figure in L5 is between multiple ranges, ie if L5 is less or equal to 400, return a value, if L5 is equal or greater than 401, but less or equal to 1100, return a different value, and if L5 is greater or equal to 1101, but less or equal to 2300, return a separate value.

    What I have is:

    =if(L5<=400,4,if(AND(L5>=401,L5<=1100),5,if(AND(L5>=1101,L5<=2300),6)))

    Is this a valid function - can you nest AND statements within IF statements?

    Any help would be much appreciated!

    Thanks

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF - returning a value between a range of numbers

    Something like:

    =Lookup(L5,{0,401,1101,2301},{4,5,6,"out of range"})
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    09-29-2008
    Location
    UK
    Posts
    2

    Re: IF - returning a value between a range of numbers

    Quote Originally Posted by NBVC View Post
    Something like:

    =Lookup(L5,{0,401,1101,2301},{4,5,6,"out of range"})


    Thanks - i've tried this, but returns the value "4" no matter the value of L5.
    I'll keep trying!


    Thanks

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF - returning a value between a range of numbers

    Are you certain that you are entering your numbers in L5?

    Also check that you have automatic calculations on.

    In XL2003 -, go to Tools|Options and then in Calculation tab, check Automatic on.

    In XL2007 +, go to the Formulas Tab and in the Calculations section, click Calculation Options and check Automatic.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: IF - returning a value between a range of numbers

    Also pay attention to the fact that the two arrays are between curly brackets {}

  6. #6
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: IF - returning a value between a range of numbers

    lookup is the way to go but back to your if

    =if(L5<=400,4,if(L5<=1100,5,if(L5<=2300),6,"Not in Range")))

    the and are not needed since the first condition determines that the second if is only done if the number is greater than 400, the same with the second we know its greater than 1100 already!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


+ 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