+ Reply to Thread
Results 1 to 7 of 7

look for nearest specific value and result value from a cell in same row

  1. #1
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    look for nearest specific value and result value from a cell in same row

    In column C, I would like the formula to search for the nearest row (looking only in above rows) with the same value as in column A, and result is the value B of the found row. Here's an example:


    A B C
    2 5 0
    1 9 0
    3 8 0
    1 2 9
    2 4 5
    4 4 0
    1 9 2
    1 6 9

    So if we look at the second last row as the 1 9 2, I will explain how those numbers came about. The user enters the number in rows A and B, they just happen to be 1 and 9. However the formula entered the number 2 in row C by looking for the value 1 (column A) nearest above it, not below! Then it shows the value 2 (from column B of the found row).

    If you look at any row in my above example, the result in (C) of any row is correct. Sometimes the result is 0, if there is nothing found by the formula.

    Thanks!
    Last edited by nenadmail; 01-27-2014 at 09:29 AM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,603

    Re: look for nearest specific value and result value from a cell in same row

    Could you give some more examples please, I can't quite follow the logic (posting a sample sheet would help)

  3. #3
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: look for nearest specific value and result value from a cell in same row

    sample.xlsx

    ok here's the example sheet. Except, in row C I will supply what's supposed to be the the correct result, but this is where I need to formula to be. I'll try another set of numbers to give you more examples.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: look for nearest specific value and result value from a cell in same row

    Hi,

    Perhaps, in C2 and copy down:

    =IF(COUNTIF(A$1:A2,A2)=1,0,LOOKUP(2,1/(A$1:A1=A2),B$1:B1))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: look for nearest specific value and result value from a cell in same row

    Here's another example attached with Apples and Oranges... maybe this example will help more.
    sample2.xlsx

  6. #6
    Forum Contributor
    Join Date
    05-19-2012
    Location
    Croatia
    MS-Off Ver
    Excel 2007
    Posts
    200

    Re: look for nearest specific value and result value from a cell in same row

    Seems to work... that's it. Thank you very much!

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: look for nearest specific value and result value from a cell in same row

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Searching cell for text in specific location and pasting result in another cell
    By AWM1966 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2012, 12:02 AM
  2. Rounding Formula Result to nearest $0.05
    By hicountry in forum Excel General
    Replies: 3
    Last Post: 08-29-2010, 11:45 PM
  3. Round the result of a formula to the nearest 0.5
    By bazza74 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-17-2009, 02:28 AM
  4. Replies: 3
    Last Post: 01-21-2009, 05:37 AM
  5. Replies: 1
    Last Post: 02-23-2006, 01:50 PM

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