How to Calculate Distance Between Two Cities in Excel
Use this interactive calculator to compute great-circle distance, route-adjusted distance, and estimated travel time. You also get an Excel-ready formula you can paste into your workbook.
City A Coordinates
City B Coordinates
Calculation Options
Result Preview
Expert Guide: How to Calculate Distance Between Two Cities in Excel
If you are trying to calculate distance between two cities in Excel, you are solving one of the most useful spreadsheet problems in logistics, sales territory planning, field service routing, travel budgeting, and geographic reporting. Excel does not include a single built-in function named DISTANCE, but it can absolutely calculate city-to-city distance with high accuracy if you combine latitude and longitude coordinates with a trigonometric formula. The most common method is the Haversine formula, which estimates great-circle distance across the Earth.
Great-circle distance is the shortest distance between two points on a sphere. It is ideal for airline-style straight-path estimates. If you need road distance, you can still start with great-circle distance and then apply a route adjustment factor, or use a mapping API for turn-by-turn distance. In many business models, the Haversine result plus a calibration factor gives you an excellent estimate while staying fully inside Excel.
What You Need Before You Start
- City names (for readability only)
- Latitude and longitude in decimal degrees for each city
- A consistent Earth radius value and unit choice (km, miles, or nautical miles)
- A clear rule for whether you need direct distance or route-adjusted distance
Reliable coordinate sources matter. If your coordinates are inconsistent, your formula can be perfect and still produce unreliable output. For high-confidence public datasets and geodetic references, review official resources such as the U.S. Census Gazetteer files and NOAA geodesy tools:
- U.S. Census Gazetteer Files (.gov)
- NOAA National Geodetic Survey Coordinate Tool (.gov)
- USGS Earth size reference information (.gov)
Step by Step Setup in Excel
Use this structure in your worksheet:
- Column A: City A
- Column B: Latitude A
- Column C: Longitude A
- Column D: City B
- Column E: Latitude B
- Column F: Longitude B
- Column G: Distance output
Then place this Haversine formula in cell G2 for kilometers:
=2*6371*ASIN(SQRT(POWER(SIN((RADIANS(E2)-RADIANS(B2))/2),2)+COS(RADIANS(B2))*COS(RADIANS(E2))*POWER(SIN((RADIANS(F2)-RADIANS(C2))/2),2)))
To return miles, replace 6371 with 3958.8. For nautical miles, use 3440.1. Fill down to calculate many city pairs at once.
Why This Formula Works
Excel trigonometric functions operate in radians, not degrees. That is why RADIANS() appears multiple times. The formula computes angular distance first, then multiplies by Earth radius in your selected unit. In simple terms, the formula performs these operations:
- Converts both coordinates from degrees to radians
- Calculates latitude and longitude deltas
- Computes an intermediate value using sine and cosine
- Uses ASIN and square root to derive the central angle
- Multiplies by Earth radius to get linear distance
City Distance Examples (Great-Circle Approximation)
| City Pair | Approx Distance (km) | Approx Distance (miles) | Typical Route Ratio (Road / Great-circle) |
|---|---|---|---|
| New York to Los Angeles | 3,936 km | 2,445 mi | About 1.13 to 1.16 |
| Chicago to Houston | 1,514 km | 941 mi | About 1.15 to 1.22 |
| London to Paris | 344 km | 214 mi | About 1.20 to 1.35 |
| Sydney to Melbourne | 714 km | 444 mi | About 1.02 to 1.10 |
These values are realistic approximations used in planning scenarios. Exact outputs vary by coordinate precision and whether you use city center coordinates, metro centroids, or administrative boundaries.
Great-Circle Distance vs Real Route Distance
A common mistake is to assume that formula distance equals driving distance. It does not. Haversine gives shortest spherical path, while roads must follow terrain, legal paths, and infrastructure. That is why route distance can be 10 percent to 35 percent longer depending on region. For aviation planning and high-level forecasting, great-circle distance is usually the correct baseline. For delivery operations, route distance is typically better.
| Method | Input Requirements | Typical Accuracy Use Case | Speed at Scale |
|---|---|---|---|
| Haversine in Excel | Lat/Lon only | Excellent for straight-path comparison and regional analysis | Very fast for thousands of rows |
| Haversine + Route Factor | Lat/Lon + calibrated multiplier | Good for cost and time modeling when APIs are not available | Very fast, easy to maintain |
| Mapping API Route Distance | Addresses or coordinates + API key | Highest realism for driving and operations | Depends on API limits and request volume |
Improving Accuracy in Real Projects
1) Use Consistent Coordinate Precision
At least 4 to 6 decimal places is recommended for city-level work. Reduced precision can shift distance noticeably, especially when points are close together.
2) Standardize Earth Radius Across Workbook
Do not mix 6371 and 6378 in different formulas unless you intentionally model a specific ellipsoid. For most business reporting, one radius per workbook is the cleanest approach.
3) Add Validation Rules
- Latitude must be between -90 and 90
- Longitude must be between -180 and 180
- Blank or text coordinates should return a friendly error message
4) Build Named Ranges or Excel Tables
If you convert your dataset to an Excel Table, formulas fill down automatically and remain readable. Named ranges also reduce errors in large models.
Advanced Excel Formula Patterns
If you use modern Excel, LET() can improve readability and performance by calculating repeated components once. Example structure:
=LET(lat1,RADIANS(B2),lon1,RADIANS(C2),lat2,RADIANS(E2),lon2,RADIANS(F2),dlat,lat2-lat1,dlon,lon2-lon1,a,POWER(SIN(dlat/2),2)+COS(lat1)*COS(lat2)*POWER(SIN(dlon/2),2),2*6371*ASIN(SQRT(a)))
This version is easier to audit, especially in enterprise files where multiple analysts maintain the same workbook.
Common Errors and How to Fix Them
- Wrong sign for longitude: West longitudes are negative in decimal format.
- Radians omitted: If you skip RADIANS(), results can be wildly wrong.
- Copy-paste mismatch: Ensure row references are aligned for both city points.
- Unexpected route distance: Remember route factor is an estimate, not turn-by-turn navigation.
When to Use Excel and When to Use an API
Excel is ideal when you need quick, transparent, and auditable distance calculations in batch form. It is especially good for quote tools, budget planning, territory alignment, and internal BI prep. APIs are better if you need live traffic, legal route constraints, vehicle types, toll handling, or strict dispatch-level accuracy. Many teams start with Excel Haversine for planning and upgrade to APIs when operational complexity grows.
Practical Workflow You Can Reuse
- Collect coordinates from a trusted source.
- Calculate great-circle distance with Haversine in Excel.
- Compare against known route values for a sample of trips.
- Determine a route adjustment factor by region.
- Apply that factor for scalable forecasting.
- Monitor actual trip logs and recalibrate quarterly.
This approach balances speed and realism, and it is commonly used in sales operations, logistics finance, and field workforce planning.
Final Takeaway
To calculate distance between two cities in Excel, use latitude and longitude with the Haversine formula. This gives you a mathematically strong baseline that is easy to automate across thousands of rows. If you need a practical travel estimate, multiply by an evidence-based route factor. By combining clean data, consistent formulas, and routine validation, you can build a distance model in Excel that is both trustworthy and decision-ready.