+ Reply to Thread
Results 1 to 3 of 3

Finding closest higher value from the list

Hybrid View

  1. #1
    Registered User
    Join Date
    06-01-2013
    Location
    Croatia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Angry Finding closest higher value from the list

    Hi all,

    I have a slight problem.

    In the file i have attached there is a list of values in column A which spreads from A2:A62. Those are fixed values. Cell C1 is a cell to input a value for comparison, and C2 cell contains formula that determines value closest to it. I downloaded a file containing the formula i needed which works fine. The formula is:

    =INDEX(A2:A62;MATCH(MIN(ABS(A2:A62-C1));ABS(A2:A62-C1);0))

    I need to add IF clause to get closest higher value instead of closest value which wouldn't be a problem if formula worked after i try to edit it. Even if i change nothing or type the formula in from scratch it still refuses to work.

    I tried to use evaluate formula on original formula and the formula i type in (which look the same). What i got is in case of original C2 formula starting value is value of C1 cell
    =INDEX(A2:A62;MATCH(MIN(ABS(A2:A62-C1));ABS(A2:A62-C1);0))
    while in edited formula (just pressed enter in formula input area without changing anything) starting value is A2:A62 array
    =INDEX(A2:A62;MATCH(MIN(ABS(A2:A62-C1));ABS(A2:A62-C1);0))
    which i think is causing my problem

    any help or link to a topic that could help me would be great

    THX in advance

    P.S.
    When i try to open attached file in openoffice calc i get:
    504 Parameter list error Function parameter is not valid, for example, text instead of a number, or a domain reference instead of a cell reference.

    P.P.S.

    SOLVED: just used VLOOKUP instead like this
    =VLOOKUP(C1;A2:A62;1;1)

    or in case of closest higher it goes like:
    =IF(C1<A2;A2;IF(VLOOKUP(C1; A2:A62; 1)>=C1;VLOOKUP(C1; A2:A62; 1);INDEX(A2:A62;MATCH(VLOOKUP(C1; A2:A62; 1);A2:A62)+1)))
    Attached Files Attached Files
    Last edited by Lem Treursić; 06-01-2013 at 11:47 AM. Reason: Solved the problem

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Finding closest higher value from the list

    Thank you for the solution.

    In future, you can post the solution as post 2 of your thread, so others can easily understand which is the question and which is the solution.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-01-2013
    Location
    Croatia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Finding closest higher value from the list

    SOLUTION:

    just used VLOOKUP instead like this
    =VLOOKUP(C1;A2:A62;1;1)

    or in case of closest higher it goes like:
    =IF(C1<A2;A2;IF(VLOOKUP(C1; A2:A62; 1)>=C1;VLOOKUP(C1; A2:A62; 1);INDEX(A2:A62;MATCH(VLOOKUP(C1; A2:A62; 1);A2:A62)+1)))


    Thanks for the remark Arlu, posting solution as a new replay as suggested.

    I'm new to this forum and felt silly replaying to myself, will do in future when i solve my own posts.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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