Great circle distance Microsoft Excel Function

Just because you have to use excel once in a while, here's a little vba function for calculating distance between two points using the great circle distance formula.



Public Function fxGreatCircleDistance( _
pLat1 As Double, _
pLong1 As Double, _
pLat2 As Double, _
pLong2 As Double)
vDenom = 57.29577951
fxGreatCircleDistance = _
6372.795 * _
(Application.Acos(Round((Sin(pLat1 / vDenom) * _
Sin(pLat2 / vDenom)) + (Cos(pLat1 / vDenom) * _
Cos(pLat2 / vDenom) * _
Cos(pLong2 / vDenom - pLong1 / vDenom)), 15)))

Until next time...Rich

Comments

JP said…
If you were interested, here's a way to get the latitude and longitude for your function:

http://www.codeforexcelandoutlook.com/excel-vba/latitude-longitude-functions/
Alexis said…
Todat I was working with my MS Excel and accidentally light down.All my data was damaged.I couldn't know what to do.But fortunately on the net I saw-microsoft excel 2007 recovery tool.Tool decided my issues very easy and free of cost.My friends were lucky too.