+ Reply to Thread
Results 1 to 6 of 6

Finding Closest Point and Distance

  1. #1
    Registered User
    Join Date
    04-01-2011
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    53

    Finding Closest Point and Distance

    Please see attached example file. I would like to get the closest point ID from Sheet2 for each point in Sheet1.
    Attached Files Attached Files
    Last edited by batman07; 08-25-2017 at 08:03 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: Finding Closest Point and Distance

    You can find the distance between two points with
    dist = sqrt[ (x1-x2)2 + (y1-y2)2 ]

    Write some code to load the inputs into arrays, then create a grid by finding the distance between each point in one array with each point in the other array. Then for each point, find the smallest distance value.
    Design everything to be as simple as possible, but no simpler.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Finding Closest Point and Distance

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Valued Forum Contributor
    Join Date
    03-16-2017
    Location
    UK
    MS-Off Ver
    2016
    Posts
    371

    Re: Finding Closest Point and Distance

    Nitpicking here, but you don't need the ABS() function since any number raised to an even power will always be positive

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Finding Closest Point and Distance

    I agree... on both points.

  6. #6
    Registered User
    Join Date
    04-01-2011
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    53

    Re: Finding Closest Point and Distance

    That solved my problem. Thank you very much. (Reputation added)
    Simply hit the star button to say THANK YOU.

+ 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. Slope, distance, expeculating next point on a line
    By kaiknux in forum Excel General
    Replies: 1
    Last Post: 01-26-2015, 07:57 AM
  2. [SOLVED] GeoCoding - Find the closest point
    By ZiadzExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2015, 03:44 PM
  3. shortest distance between a point and a line
    By stockgoblin42 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-04-2013, 02:18 PM
  4. Geofencing Lat / Longs (Finding Closest Point) in Excel
    By mattkunkle in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-19-2013, 02:05 PM
  5. Replies: 5
    Last Post: 10-23-2011, 03:44 PM
  6. Distance from a point to a curve
    By bjack205 in forum Excel General
    Replies: 14
    Last Post: 02-04-2011, 02:10 PM
  7. Perpendicular distance of a point from linear regression line?
    By Winny in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 09-24-2005, 08:05 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