Calculate distance in km between 2 coordinates (longitude ,latitude)

Samir_

New Member
Joined
Jul 12, 2023
Messages
3
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
Platform
  1. Windows
Hi
I need a formula in excel 365 to find the distance in km between two coordinates (longitude ,latitude)

I had tried these twos formulas
=6371 * ACOS(COS(RADIANS(90-B2)) * COS(RADIANS(90-B3)) + SIN(RADIANS(90-B2)) * SIN(RADIANS(90-B3)) * COS(RADIANS(A2-A3)))
=2*ASIN(SQRT((SIN((B3-B2)/2))^2+COS(B2)*COS(B3)*(SIN((A3-A2)/2))^2))*6371

But they are not giving the same result and they did not match the result in google maps

TIA

-Samir
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Are you looking at the distance in a straight line or via roads?

Do you have a Google API key/ account?
Do you have a HERE maps API key/ account?
 
Upvote 0
The below seems to do it, which is what you had:
Book1
ABCDEF
1LatLongKM'sMiles
2From51.406710.40932658.0182914.982334
3To51.366380.5051189
Sheet1
Cell Formulas
RangeFormula
E2E2=6371*ACOS(COS(RADIANS(90-B2))*COS(RADIANS(90-B3))+SIN(RADIANS(90-B2))*SIN(RADIANS(90-B3))*COS(RADIANS(C2-C3)))
F2F2=E2*0.621371


Checked on the below
Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript

Maybe you could explain more and possibly provide the lat longs you are working with and the discrepancy you are having?
 
Upvote 0
Solution
The below seems to do it, which is what you had:
Book1
ABCDEF
1LatLongKM'sMiles
2From51.406710.40932658.0182914.982334
3To51.366380.5051189
Sheet1
Cell Formulas
RangeFormula
E2E2=6371*ACOS(COS(RADIANS(90-B2))*COS(RADIANS(90-B3))+SIN(RADIANS(90-B2))*SIN(RADIANS(90-B3))*COS(RADIANS(C2-C3)))
F2F2=E2*0.621371


Checked on the below
Calculate distance and bearing between two Latitude/Longitude points using haversine formula in JavaScript

Maybe you could explain more and possibly provide the lat longs you are working with and the discrepancy you are having?

Thank you. that's works well and the link was very helpful
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

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