+ Reply to Thread
Results 1 to 10 of 10

How to find nearest value in excel?

  1. #1
    Registered User
    Join Date
    10-22-2019
    Location
    Qatar
    MS-Off Ver
    2013
    Posts
    58

    Smile How to find nearest value in excel?

    Dear All,
    I need to find nearest value(point). how can find in Excel or another software?
    For the same value i can use "vlookup" but for nearest i don't know.
    please guide me.
    Please check the attached file for your reference.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: How to find nearest value in excel?

    What do you mean by nearest?

    The nearest value above, below, or either?
    Applied to Eastings, or Northings, or both? If both, how?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: How to find nearest value in excel?

    Based on nearest EASTINGS:

    E3
    =INDEX(K:K,MATCH($F3,$L:$L,0))

    F3:
    =LOOKUP(0,0/FREQUENCY(0,ABS($L$3:$L$21-B3)),$L$3:$L$21)

    G3:
    =INDEX(M:M,MATCH($F3,$L:$L,0))
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-22-2019
    Location
    Qatar
    MS-Off Ver
    2013
    Posts
    58

    Re: How to find nearest value in excel?

    Dear Mr.Glenn Kennedy,
    Thank you so much.
    It's working, it's really good solution.
    You saved my time.
    Once again Thank You

  5. #5
    Registered User
    Join Date
    10-22-2019
    Location
    Qatar
    MS-Off Ver
    2013
    Posts
    58

    Re: How to find nearest value in excel?

    Dear Mr.Glenn Kennedy,

    You asked yesterday like this,
    "What do you mean by nearest?

    The nearest value above, below, or either?
    Applied to Eastings, or Northings, or both? If both, how?"

    Today only i found the issue

    With your previous method it's not possible, i have attached same file with some changes for better understand.

    Is there any option to find out with the nearest with "distance"?

    Please guide me.
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: How to find nearest value in excel?

    If you need further assistance, I suggest you remove the SOLVED tag from the thread.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: How to find nearest value in excel?

    Try this out.

    If it's incorrect, please use cell shading on this sheet to show correct results.
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: How to find nearest value in excel?

    A bit more research has produced this. There are now 3 choices for you (all yielding the same answer). I have changed the data layout a little (re-ordering columns, nothing more) as I'm going to keep this solution on file...

    Option 1:
    =LOOKUP(1,1/FREQUENCY(0,MMULT(($F$3:$G$21-$B3:$C3)^2,{1;1})),E$3:E$21)

    copied across and down.

    Option 2:
    =LOOKUP(1,1/FREQUENCY(0,SIN((RADIANS(F$3:F$21-B3))/2)^2+SIN((RADIANS(G$3:G$21-C3))/2)^2*COS(RADIANS(F$3:F$21))*COS(RADIANS(B3))),F$3:F$21)

    array-entered and copied down (the most accurate formula, apparrently!!). Then a simple INDEX-MATCH to return the other two parameters.

    Option 3:
    INDEX(E$3:E$21,MATCH(MIN(SQRT(($F$3:$F$21-$B3)^2+($G$3:$G$21-$C3)^2)),SQRT( ($F$3:$F$21-$B3)^2+($G$3:$G$21-$C3)^2),0),1)

    array-entered copied across and down. It's based on the SQRT of the sums of squares of the differences, as per your manual calculations.

    See sheet for data layouts.


    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-22-2019
    Location
    Qatar
    MS-Off Ver
    2013
    Posts
    58

    Re: How to find nearest value in excel?

    Dear Mr.Glenn Kennedy,

    Thank you so much,
    Option 2 is not giving correct value.
    But other two options are very good solution.

    Thank you for spending your valuable time for me.
    Really you are very good. God bless you.

    Once again thank you

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,055

    Re: How to find nearest value in excel?

    For my own interest, can you show me an example where it DOES NOT work? My guess is negative eastings or northings???


    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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] Find Nearest Date
    By hkbhansali in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 07-13-2019, 11:04 AM
  2. [SOLVED] Find nearest date in excel Index Match for two column
    By hkbhansali in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-29-2019, 05:43 AM
  3. FInd closest/nearest match in excel
    By Ribband in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-20-2018, 09:39 AM
  4. Have issue at work, please help with find nearest point by using VBA or excel fomula
    By robert12345 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2016, 11:19 PM
  5. How to find nearest date to that of given
    By TRJJK73 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-16-2008, 06:30 PM
  6. Find nearest value
    By Two-Canucks in forum Excel General
    Replies: 7
    Last Post: 05-19-2006, 02:55 PM
  7. find nearest help
    By nobbyknownowt in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-21-2006, 08:40 AM

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