Anybody use VBA?

Author
Discussion

mcecm

Original Poster:

674 posts

268 months

Wednesday 4th June 2003
quotequote all
Using VB in excel, I have to draw a line between a random point and the closest point on a polygon. I've got the random point and the polygon but can't figure out the code to calculate the closest point. Can anyone help?

pdV6

16,442 posts

262 months

Wednesday 4th June 2003
quotequote all
Sorry, no code sample!

However, assuming that you have (x,y) coordinates for your random point and (x,y) coords for the points that make up your polygon, it would seem simple to write a routine that calculates the distance between 2 given points using pythagorus.

Shortest result gives the endpoint of the line.

HTH