Don't worry, I'm here to help! Here's a
step-by-step guide on how to find the closest coordinate match between two arrays of (x,y) coordinates in Excel:
- First, create a new column in your Actual array for the closest Design coordinate. You can label this column "Closest Design".
- Next, for each Actual coordinate, you will need to calculate the distance to every Design coordinate. You can use the Pythagorean theorem to calculate the distance between two points:
Code:
=SQRT((Actual_x-Design_x)^2+(Actual_y-Design_y)^2)
- To calculate the distance between each Actual coordinate and every Design coordinate, you can use the following formula in a new column next to your Actual coordinates:
Code:
=SQRT((Actual_x-Design_x)^2+(Actual_y-Design_y)^2)
- Once you have calculated the distance between each Actual coordinate and every Design coordinate, you can use the MIN function to find the smallest distance. In the "Closest Design" column, enter the following formula:
Code:
=MIN(range of distances)
- The range of distances should include all of the distances you calculated in step 3 for the corresponding Actual coordinate. For example, if your Actual coordinates are in columns A and B, and your Design coordinates are in columns C and D, the range of distances for the first Actual coordinate would be: , where E2 is the first cell with the distance formula and 501 is the last row with a distance formula.
- Finally, you can use conditional formatting to highlight any Design coordinates that do not have a match in the Actual array. To do this, select the Design coordinates and go to Home Conditional Formatting New Rule. Choose "Use a formula to determine which cells to format" and enter the following formula:
Code:
=ISNA(MATCH(Design_x,Actual_x,0))
where Design_x is the cell with the x-coordinate of the Design coordinate, and Actual_x is the range of x-coordinates in the Actual array. Choose a formatting style to highlight the cells without a match.
That's it! You should now have a column in your Actual array with the closest Design coordinate for each Actual coordinate, and any Design coordinates without a match should be highlighted.