Distance between latitude and longitude

F

Fazna Ali

I want to calculate distance between two latitude and longitud
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 exce
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
+-------------------------------------------------------------------
 
R

Ron Rosenfeld

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top