Distance between latitude and longitude
On Wed, 7 Nov 2012 02:42:03 +0000, Fazna Ali wrote:
I want to calculate distance between two latitude and longitude
coordinate.
The macro turn to have
compile error:
Argument not optional
i think it because of the
Cells(i, 5) = GreatCircleDistance(Lat1, long1, Lat2, long2)
does not declare all argument from the GreatCicrcleDistance function.
but when i put all the arguments to the equation, nothing is happen.
Actually how to apply the function so it can be use in the excel
sheet.?
Btw, i've attached the xsl file together in this thread.
Please take a look on it.
Thank you very much.
+-------------------------------------------------------------------+
|Filename: DistanceLatLon.zip |
|Download: http://www.excelbanter.com/attachment.php?attachmentid=669|
+-------------------------------------------------------------------+
Your macro doesn't even get that far.
Function GreatCircleDistance(Latitude1 As Double, Longitude1 As Double, _
Latitude2 As Double, Longitude2 As Double, _
ValuesAsDecimalDegrees As Boolean, _
ResultAsMiles As Boolean) As Double
On your worksheet, your latitude and longitude are both text strings, not doubles; and you didn't bother to enter anything for the non-optional arguments: ValuesAsDecimalDegrees or ResultAsMiles.
Any or all of that will result in a #VALUE! error.
|