简体   繁体   中英

Find closest match x,y,z points in 2 columns, then calculate distance [Excel VBA or Formula]

I need to compare thousands of points in a before column (A) and an after column (H). How do I

  1. Find the closest match based on the XYZ coordinates?
  2. Calculate the distance to the closest match (pythagorean theorem =SQRT((B2-I2)^2+(C2-J2)^2+(D2-K2)^2)) ?

Picture of what I am trying to do

在此处输入图像描述

Before Name X   Y   Z               After Name  X   Y   Z   Closest Match   Distance to Closest Point
Point 1 1   2   3               Point A 1.6 2.1 3.1 Point B 0.6164414
Point 2 1.5 2   3               Point B 1   2.1 2.9 Point A 0.519615242
Point 3 2   3   4               Point C 2   3   4   Point C 0

This problem can be solved by

  1. Creating a distance matrix for points in before and after column
  2. MIN function to identify minimum distance
  3. Combination of MATCH and INDEX function to find closest match

Below is the solution to a sample data:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM