How to calculate the distance between two points in Excel
Formula (Excel and Google Sheets)
=SQRT((D2-B2)^2+(E2-C2)^2)Use the Pythagorean formula: =SQRT((D2-B2)^2+(E2-C2)^2).
- Result on the example
- one result per row in
F2, filled down toF6 - Works in
- Every current version
- Google Sheets
- Same formula
See it work
The formula is already in F2, filled down to F6. Change any input and the result updates, or edit the formula to experiment.
How it works
The horizontal and vertical differences are the two short sides of a right triangle, and the distance is the long side: √(dx² + dy²). For segment A that is √(3² + 4²) = 5. Squaring makes the order of the points irrelevant, so negative differences are fine.
=SQRT((D2-B2)^2+(E2-C2)^2)Result5
D23The value in D2.
B20The value in B2.
D2-B23The - operator subtracts.
D2-B2)^29The ^ operator raises to a power.
E24The value in E2.
C20The value in C2.
E2-C24The - operator subtracts.
E2-C2)^216The ^ operator raises to a power.
D2-B2)^2+(E2-C2)^225The + operator adds.
SQRT((D2-B2)^2+(E2-C2)^2)5SQRT: Square root.- number
D2-B2)^2+(E2-C2)^225
- number
In Google Sheets
The same formula works in Google Sheets: =SQRT((D2-B2)^2+(E2-C2)^2). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =((D2-B2)^2+(E2-C2)^2)^0.5 | 5.00, 10.00, 10.00… | Raising to the power 0.5 is the same as SQRT. |
Common mistakes
- Latitude and longitude are not flat X/Y coordinates. Over more than a few miles you need the haversine formula.
- Both coordinates must be in the same unit; mixing feet and meters gives a meaningless distance.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Calculate the distance between two points
F2, calculate the straight-line distance from (X1, Y1) to (X2, Y2), then fill down to F6.Questions
How do I calculate distance in 3D?
Add the third difference: =SQRT((D2-A2)^2+(E2-B2)^2+(F2-C2)^2) with the coordinates laid out accordingly.
How do I calculate distance between latitude and longitude?
Use the haversine formula: =6371*2*ASIN(SQRT(SIN(RADIANS(lat2-lat1)/2)^2+COS(RADIANS(lat1))*COS(RADIANS(lat2))*SIN(RADIANS(lon2-lon1)/2)^2)) gives kilometers.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.