Distance Between Two Points . .

Evagrius Ponticus

Well-known Member
Joined
May 24, 2007
Messages
1,467
Hi all,

I may be pushing the limits of this board with this question, but does anyone know if there is a code that can calculate the the distance between the latitude and longitude of two points on a map. For example, how can I calculate the distance between these two points. Thanks for any help.

.......................................Long: Lat:

Albuquerque NM -106.6225897 35.0846


Las Cruces NM -106.716125 32.6621
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I don't have code, but here is a formula.

=ACOS((SIN(Lat1)*SIN(Lat2))+(COS(Lat1)*COS(Lat2)*COS(long2-long1)))

Then that result multiplied by 3963.191 (diameter of the earth at the equator).

Google "Great Circle Distance" and you'll find similar formulas.

If that's the only points you needed to calc. the distance is 167.6521489521 miles, or 269.80998000317 KM, or 885203.3464671 Feet :), or...yea ok, I'm done bein stupid, but anyhow 168ish miles
 
Last edited:
Upvote 0
OK, I have a WB with a userform (had to find it) to do this also, but I'm not allowed to post attachments (not sure why)...but feel free to PM me an email addy and I'll be happy to share.
 
Upvote 0
Jproffer - dude - I'd be grateful for any help on this. I have been struggling all day to get this right. I have an excel sheet will the long and lat of all cities in US. I tried the formula you posted and prior to the final multiplication - I get 2.42 - that isn't right. Using the sample data in my initial post, below is the formula I used.

Code:
=ACOS((SIN(35.0846)*SIN(32.6621))+(COS(35.0846)*COS(32.6621)*COS((-106.716)-(-106.623))))
 
Upvote 0
No that isn't right...I'm sorry I left out a FAIRLY :) important piece of information.

The Lat and Long has to be in Radians which I believe is Deg/180*Pi, but at any rate its

(Worksheet Function) Radians(whatever cell your lat or long are in) each one seperately, needless to say.
 
Upvote 0
great - now I get the same answer as you did 168m. Yahoo maps has 224 - I am guessing that driving distance is different than then how we figured it out?
 
Upvote 0
I'm sure it is...seein as how you have to follow those pesky roads and all :)...just messin.

Great circle distance is as the crow flies but even still...I can't imagine its 56 miles more over 168 miles...but maybe. Winding (very winding) roads???
 
Upvote 0

Forum statistics

Threads
1,214,986
Messages
6,122,611
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top