Find a description of the algorithm online. You'll see it's fairly
basic geometry, and VBA will be able to handle it without any add-ins
(though if you didn't care for writing the code, that's one way you
could buy it).
-Tom.
>I would like to compute the great circle distance between 2
>destinations with the lat and long information provided.
[quoted text clipped - 7 lines]
>
>Velocity
velocityinc@gmail.com - 31 Jan 2008 11:49 GMT
> Find a description of the algorithm online. You'll see it's fairly
> basic geometry, and VBA will be able to handle it without any add-ins
[quoted text clipped - 14 lines]
>
> >Velocity
Does this GCD code work well? How can error handling be incorporated.
Function LatLonDistance(Lat1 As Double, Lon1 As Double, Lat2 As
Double, Lon2
As Double) As Double
Const Pi = 3.141592654
Const DegToStatMiles = 3958.754
Dim rLat1 As Double, rLon1 As Double, rLat2 As Double, rLon2 As
Double, X As
Double
rLat1 = Pi * Lat1 / 180
rLon1 = Pi * Lon1 / 180
rLat2 = Pi * Lat2 / 180
rLon2 = Pi * Lon2 / 180
X = Sin(rLat1) * Sin(rLat2) + Cos(rLat1) * Cos(rLat2) * Cos(rLon1 -
rLon2)
If X >= 1 Then
LatLonDistance = 0 'Error condition, I assume that the two points
are
the same
Else
LatLonDistance = DegToStatMiles * (Atn(-X / Sqr(-X * X + 1)) + 2
*
Atn(1))
End If
End Function