# How to Calculate Distance between Two GPS Coordinates in Excel

Get FREE Advanced Excel Exercises with Solutions!

In our day to day life, we feel the necessity of measuring distance in so many times. It is not so tough to calculate the distance between two GPS coordinates in Excel. I am going to elaborate 2 simple ways to calculate the distance between two GPS coordinates in Excel.
For more clarification, I will use a dataset comprising the Latitude and Longitude values of the locations Prague, Czech Republic, and Salzburg, Austria. ## 2 Simple Ways to Calculate Distance between Two GPS Coordinates in Excel

### 1.  Using Arithmetic Formula  to Calculate Distance between Two GPS Coordinates

The use of the arithmetic formula is the quickest and simplest way to calculate the distance between two GPS coordinates. Now, follow the following steps for this purpose.

Steps:

• Create a new row titled Distance (Miles).
• Select a cell to apply the following formula:
`=ACOS(COS(RADIANS(90-C5))*COS(RADIANS(90-C6))+SIN(RADIANS(90-C5))*SIN(RADIANS(90-C6))*COS(RADIANS(D5-D6)))*3959`

Here, Formula Breakdown

Output: 0.999092512926254

ACOS(0.999092512926254) ACOS Function returns the inverse Cosine value.
Output: 0.0426057358212635

0.0426057358212635 *3959 – The multiplication of 3959 converts the value into Miles.
Output: 168.676108116382

• Finally, press ENTER to have the result. Thus, we can calculate the distance between two GPS coordinates quite easily.

### 2. Using VBA to Calculate Distance between Two GPS Coordinates

We can also use VBA to calculate the distance between two GPS coordinates. It is the smartest way to do so.

Steps:

• First of all, go to the Developer tab.
• Choose Visual Basic from the ribbon. • Now, click on Insert.
• Then, press on Module. • Now, Input the following VBA code in the empty space:
``````Public Function DistCalc(Prague_Lati As Double, Prague_Longi As Double, Salzburg_Lati As Double, Salzburg_Longi As Double)
With WorksheetFunction
'Change 6371 to 3959 to get your result in Miles
DistCalc = .Acos(M * N + O * P * Q) * 6371
End With
End Function`````` Firstly, I used here a Public Function procedure DistCalc. Then, I set some variables M, N, O, P, and Q with certain values. I mentioned a suitable relation between the variables to define the DistCalc Function.

• Now, select a cell to have the measured result (i.e. C8).
• Now, apply the following formula:
`=DistCalc(C5,D5,C6,D6)`

Here, the DistCalc function estimates the distance between the two points. • Finally, hit ENTER. This is the coolest way to calculate the distance between two GPS coordinates.

## Practice Section

You can practice here for more expertise. ## Conclusion

In this article, I have tried to articulate 2 simple ways to calculate the distance between two GPS coordinates in Excel. I hope it will be helpful for all. For any further questions, comment below.

## Related Articles Naimul Hasan Arif

Hello, I am Arif. I am an Engineer who graduated from BUET. I want to pursue an enterprising career in a progressive environment where my skills & knowledge can be enhanced to their maximum potential to contribute to the overall success and growth of the organization.

1. Reply Thank YOU!!

• Reply Shamima Sultana Aug 13, 2023 at 10:33 AM

Dear Justice,

You are most welcome.

Regards
ExcelDemy Advanced Excel Exercises with Solutions PDF  