+ Reply to Thread
Results 1 to 9 of 9

Lookup Hi / Lo

  1. #1
    Registered User
    Join Date
    11-26-2004
    Posts
    5

    Lookup Hi / Lo

    I'm trying to do what i think is quite a simple function.

    I have a data array (B5:B13) with the following values in it:

    14
    40
    45
    59
    70
    79
    90
    100
    280

    my reference cell is C16 and is currently set to 63.

    I would like cell C18 to display the closest match below 63 (in this example 59), i have acheived this with the forumula =LOOKUP(C16,B5:B13,B5:B13).

    But i want cell C19 to display the closest value above 63 i.e. 70.

    I have tried the offset function but can't appear to get it to work, and would prefer a lookup function if possible.

    Thanks in advance,

    Chris

  2. #2
    bj
    Guest

    RE: Lookup Hi / Lo

    an index(match())
    combo will probably do whhat you want
    =index(range,match(63,range,1))
    for value less than 63 and
    =index(range,match(63,range,-1))
    for vlaue above 63
    "chrisabberton" wrote:

    >
    > I'm trying to do what i think is quite a simple function.
    >
    > I have a data array (B5:B13) with the following values in it:
    >
    > 14
    > 40
    > 45
    > 59
    > 70
    > 79
    > 90
    > 100
    > 280
    >
    > my reference cell is C16 and is currently set to 63.
    >
    > I would like cell C18 to display the closest match below 63 (in this
    > example 59), i have acheived this with the forumula
    > =LOOKUP(C16,B5:B13,B5:B13).
    >
    > But i want cell C19 to display the closest value above 63 i.e. 70.
    >
    > I have tried the offset function but can't appear to get it to work,
    > and would prefer a lookup function if possible.
    >
    > Thanks in advance,
    >
    > Chris
    >
    >
    > --
    > chrisabberton
    > ------------------------------------------------------------------------
    > chrisabberton's Profile: http://www.excelforum.com/member.php...o&userid=16872
    > View this thread: http://www.excelforum.com/showthread...hreadid=474744
    >
    >


  3. #3
    Richard Buttrey
    Guest

    Re: Lookup Hi / Lo

    You could try

    =INDEX(B5:B13,MATCH(C16,B5:B13)+1,1)

    HTH

    On Mon, 10 Oct 2005 08:49:26 -0500, chrisabberton
    <[email protected]> wrote:

    >
    >I'm trying to do what i think is quite a simple function.
    >
    >I have a data array (B5:B13) with the following values in it:
    >
    >14
    >40
    >45
    >59
    >70
    >79
    >90
    >100
    >280
    >
    >my reference cell is C16 and is currently set to 63.
    >
    >I would like cell C18 to display the closest match below 63 (in this
    >example 59), i have acheived this with the forumula
    >=LOOKUP(C16,B5:B13,B5:B13).
    >
    >But i want cell C19 to display the closest value above 63 i.e. 70.
    >
    >I have tried the offset function but can't appear to get it to work,
    >and would prefer a lookup function if possible.
    >
    >Thanks in advance,
    >
    >Chris


    __
    Richard Buttrey
    Grappenhall, Cheshire, UK
    __________________________

  4. #4
    Domenic
    Guest

    Re: Lookup Hi / Lo

    For the largest value less than or equal to the lookup value...

    =LOOKUP(C16,B5:B13)

    For the smallest value greater than or equal to the lookup value..

    =MIN(IF(B5:B13>=C16,B5:B13))

    ....confirmed with CONTROL+SHIFT+ENTER,not just ENTER.

    Hope this helps!

    In article
    <[email protected]>,
    chrisabberton
    <[email protected]> wrote:

    > I'm trying to do what i think is quite a simple function.
    >
    > I have a data array (B5:B13) with the following values in it:
    >
    > 14
    > 40
    > 45
    > 59
    > 70
    > 79
    > 90
    > 100
    > 280
    >
    > my reference cell is C16 and is currently set to 63.
    >
    > I would like cell C18 to display the closest match below 63 (in this
    > example 59), i have acheived this with the forumula
    > =LOOKUP(C16,B5:B13,B5:B13).
    >
    > But i want cell C19 to display the closest value above 63 i.e. 70.
    >
    > I have tried the offset function but can't appear to get it to work,
    > and would prefer a lookup function if possible.
    >
    > Thanks in advance,
    >
    > Chris


  5. #5
    Harlan Grove
    Guest

    Re: Lookup Hi / Lo

    Domenic wrote...
    >For the largest value less than or equal to the lookup value...
    >
    >=LOOKUP(C16,B5:B13)


    Since this would only work when B5:B13 were sorted in ascending order,

    >For the smallest value greater than or equal to the lookup value..
    >
    >=MIN(IF(B5:B13>=C16,B5:B13))

    ....

    Richard Buttrey's formula,

    =INDEX(B5:B13,MATCH(C16,B5:B13)+1)

    would be more efficient, and it wouldn't need array entry.


  6. #6
    Domenic
    Guest

    Re: Lookup Hi / Lo

    In article <[email protected]>,
    "Harlan Grove" <[email protected]> wrote:

    > Richard Buttrey's formula,
    >
    > =INDEX(B5:B13,MATCH(C16,B5:B13)+1)
    >
    > would be more efficient, and it wouldn't need array entry.


    But the formula would return #N/A if the lookup value was 10. Shouldn't
    the correct answer be 14?

  7. #7
    Harlan Grove
    Guest

    Re: Lookup Hi / Lo

    Domenic wrote...
    >"Harlan Grove" <[email protected]> wrote:
    >>Richard Buttrey's formula,
    >>
    >>=INDEX(B5:B13,MATCH(C16,B5:B13)+1)
    >>
    >>would be more efficient, and it wouldn't need array entry.

    >
    >But the formula would return #N/A if the lookup value was 10. Shouldn't
    >the correct answer be 14?


    Boundary conditions. I'll grant that when C16 = 10, the smallest value
    in the list greater than C16 should be 14 rather than #N/A. However, if
    C16 were 300, what should the formula return? 0 (which your formula
    does) or #N/A (which provides symmetry with the LOOKUP call when C16 =
    10)? If it should return #N/A, then perhaps it should resemble

    =IF(C16<B5,B5,INDEX(B5:B13,MATCH(C16,B5:B13)+1))


  8. #8
    Harlan Grove
    Guest

    Re: Lookup Hi / Lo

    Harlan Grove wrote...
    ....
    > . . . If it should return #N/A, then perhaps it should resemble
    >
    >=IF(C16<B5,B5,INDEX(B5:B13,MATCH(C16,B5:B13)+1))


    So maybe I should have made it return #N/A.

    =IF(C16<B5,B5,IF(C16>=B13,#N/A,INDEX(B5:B13,MATCH(C16,B5:B12)+1)))


  9. #9
    Domenic
    Guest

    Re: Lookup Hi / Lo

    Yeah, I think the formula should return #N/A. In which case, your
    formula would provide the correct result. Thanks Harlan!

    In article <[email protected]>,
    "Harlan Grove" <[email protected]> wrote:

    > Boundary conditions. I'll grant that when C16 = 10, the smallest value
    > in the list greater than C16 should be 14 rather than #N/A. However, if
    > C16 were 300, what should the formula return? 0 (which your formula
    > does) or #N/A (which provides symmetry with the LOOKUP call when C16 =
    > 10)? If it should return #N/A, then perhaps it should resemble
    >
    > =IF(C16<B5,B5,INDEX(B5:B13,MATCH(C16,B5:B13)+1))


    > So maybe I should have made it return #N/A.
    >
    > =IF(C16<B5,B5,IF(C16>=B13,#N/A,INDEX(B5:B13,MATCH(C16,B5:B12)+1)))


+ 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