+ Reply to Thread
Results 1 to 7 of 7

Return the difference between a value and it's nearest upper and lower neighbour?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    NA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Return the difference between a value and it's nearest upper and lower neighbour?

    Good morning everyone!

    Another wonderful workday to troubleshoot excel! Here's what I'm having difficulty with (see attached).

    I want to take the values in column L (in purple), and find the difference between its nearest neighbors. Any ideas?

    Thanks in advance guys!
    Attached Files Attached Files

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Return the difference between a value and it's nearest upper and lower neighbour?

    hi there. try this in M2:
    =LOOKUP(L2,A2:J2)-L2

    and this in N2:
    =INDEX(A2:J2,MATCH(TRUE,INDEX(A2:J2>=L2,),0))-L2

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return the difference between a value and it's nearest upper and lower neighbour?

    Will there always be a negative result and a positive result (or 0)?

    These array formulas** work on the limited sample data in your file:

    For the lower diff:

    =MAX(IF(A2:J2-L2<=0,A2:J2-L2))

    For the upper diff:

    =MIN(IF(A2:J2-L2>=0,A2:J2-L2))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    I have a feeling that it's more complicated than this!
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    10-16-2013
    Location
    NA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Return the difference between a value and it's nearest upper and lower neighbour?

    @ Tony Valko; no, the values don't have to be either negative or positive. I will know myself.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return the difference between a value and it's nearest upper and lower neighbour?

    In that case disregard my suggestions.

    Will there always be a value less than or equal to the target value?

    Will there always be a value greater than or equal to the target value?

  6. #6
    Registered User
    Join Date
    10-16-2013
    Location
    NA
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Return the difference between a value and it's nearest upper and lower neighbour?

    Sorry I should've been much more specific.

    The values in the green columns will always be positive. However the returned values from the lower columns don't necessarily have to be negative or positive (even though they are in actuality).

    For the lowest values in the green columns, the L column values could be lower, in which case bring back the difference from the nearest top neighbor, and likewise at the other end of the green column, bringing back the difference from the nearest neighbor below it.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return the difference between a value and it's nearest upper and lower neighbour?

    Can you post a new sample file with more examples of the results you expect?

    About 20 rows worth of data should be plenty.

+ 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. upper to lower case
    By rajeshvarma in forum Excel General
    Replies: 1
    Last Post: 07-02-2011, 03:16 AM
  2. Upper and lower case in VBA
    By Mick S in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2011, 06:44 PM
  3. lower and upper chart
    By pb in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-03-2006, 04:45 PM
  4. [SOLVED] Changing file in all upper case to upper and lower case
    By Sagit in forum Excel General
    Replies: 14
    Last Post: 08-25-2005, 10:05 PM
  5. Replies: 1
    Last Post: 03-09-2005, 05:06 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