Bookmark this page: Add Locate nearst Point GPS Coordinate to Yahoo MyWeb Add Locate nearst Point GPS Coordinate to Google Bookmarks Add Locate nearst Point GPS Coordinate to Windows Live Add Locate nearst Point GPS Coordinate to Del.icio.us Digg Locate nearst Point GPS Coordinate! Add Locate nearst Point GPS Coordinate to Netscape
  •  
  • Subject
  • Author
  • Date
If you were  Registered and logged in, you could reply and use other advanced thread options
Posted by nitn28 on May 15, 2007, 2:49 pm


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


Posted by Simon Slavin on May 18, 2007, 5:28 pm


On 15/05/2007, nitn28@gmail.com wrote in message

> but i want to knw is there anyother way "more presice n accurate" to
> locate nearest point

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