
- Locate-nearst-Point-GPS-Coordinate
- 05-15-2007
![]() Re: Locate nearst Point GPS Coordinate
| Simon Slavin | 05-18-2007 |
If you were Registered and logged in, you could reply and use other advanced thread options
hello every one
i m working with GPS Coordinates [cartesian coordinates]
i want to locate nearest point at present m using this formula to
locate nearrest point
Sub sortdistance()
LastRowA = Cells(Rows.Count, "A").End(xlUp).Row
LastRowE = Cells(Rows.Count, "E").End(xlUp).Row
For i = 1 To LastRowA
X = Cells(i, "A")
Y = Cells(i, "B")
For j = 1 To LastRowE
distance = Sqr((X - Cells(j, "E")) ^ 2 + (Y - Cells(j, "F")) ^
2)
If j = 1 Then
shortX = Cells(j, "E")
shortY = Cells(j, "F")
shortdistance = distance
Else
If distance < shortdistance Then
shortX = Cells(j, "E")
shortY = Cells(j, "F")
shortdistance = distance
End If
End If
Next j
Cells(i, "C") = shortX
Cells(i, "D") = shortY
Next i
End Sub
but i want to knw is there anyother way "more presice n accurate" to
locate nearest point
hope sumbody wud find time to help me out
many thanx in advance
On 15/05/2007, nitn28@gmail.com wrote in message
There are other ways to sort the points that may or may not be faster
depending on how many points you have and how sorted they are before your
routine is run. But you're probably not going to speed that up much by
using a different sorting routine.
I have one comment on your code: there's no point in doing the 'Sqr'.
Simon.
--
http://www.hearsay.demon.co.uk
- Opinion about buying a Gps
- Garmin GPS
- 2009-12-15
- Hacking GPS - Free Book
- Magellan GPS
- 2009-02-09



> locate nearest point