Back to HERE in Excel
SheetXAI logo
HERE logo
HERE · Excel Guide

Build a Distance Matrix from Depots and Customers in Excel

The Scenario

You are a logistics planner. The route optimization model runs every Monday at 7 AM and it needs a full distance matrix:5 warehouse origins against 40 customer delivery destinations.

Your workbook has depots in the "Depots" tab (lat/lng in columns A and B) and customers in the "Customers" tab. The "Distance Matrix" tab is empty.

The bad version of Monday morning:

  • You try to update the script someone wrote six months ago
  • The script calls HERE's routing API one pair at a time and hits a rate limit after 80 calls
  • You restart, it errors on row 43
  • The model does not run. The Monday morning logistics call is in 90 minutes.

The fast version is one prompt.

The Easy Way: One Prompt in SheetXAI

SheetXAI is an AI agent inside your Excel workbook that reads both tabs and calls HERE Matrix Routing for all 200 pairs in one batch, writing results into the Distance Matrix tab.

Open the SheetXAI sidebar and type:

Use HERE Matrix Routing to compute drive times between all 5 origins in the Depots tab (lat/lng in columns A and B) and all 40 destinations in the Customers tab (lat/lng in columns A and B). Write the results as a 5×40 table in the Distance Matrix tab, with origin depot names as row headers and customer names as column headers.

SheetXAI reads both tabs, calls HERE Matrix Routing for the full set of pairs, and writes the completed distance matrix into the "Distance Matrix" tab with headers.

What You Get

A complete, labeled distance matrix in the "Distance Matrix" tab:

  • 5 rows — one per depot origin
  • 40 columns — one per customer destination
  • Named headers so the matrix is readable without cross-referencing

The routing model reads this tab directly. No reformatting, no transposing.

What If the Data Is Not Quite Ready

Matrix routing jobs are sensitive to data quality and format. SheetXAI handles the common issues in the same prompt.

When depot and customer names have inconsistent formatting

Your Depots tab uses uppercase names and your Customers tab uses title case. Headers will be inconsistent.

Normalize all depot names to title case in column C and all customer names to title case in column C before using them as headers. Then build the HERE Matrix Routing distance table in the "Distance Matrix" tab using the normalized names.

When some customer rows have missing coordinates

Column A or B is blank for 4 customer rows.

For customers in the Customers tab where column A or B is blank, write "Missing Coordinates" in column C and exclude those rows from the matrix call. For all other customers, run HERE Matrix Routing against the 5 depots and write the travel times to the "Distance Matrix" tab. List excluded customers in a note in cell A1 of the Distance Matrix tab.

When you need a subset matrix for a single depot

Today only the Manchester depot is dispatching. You do not need the full 5×40 table.

Use HERE Matrix Routing to compute drive times from only the depot in row 2 of the Depots tab to all 40 customers in the Customers tab. Write the results as a single-row-per-customer list in the "Distance Matrix" tab, with customer name in column A and travel time in minutes in column B.

When you need the matrix plus a nearest depot assignment in one pass

The routing model needs the distance matrix and also needs each customer pre-assigned to their nearest depot.

Use HERE Matrix Routing to compute drive times between all 5 depots (Depots tab, columns A and B) and all 40 customers (Customers tab, columns A and B). Write the full 5×40 matrix to the "Distance Matrix" tab. Then in the Customers tab, add a "Nearest Depot" column (column C) for each customer, writing the name of the depot with the shortest travel time to that customer.

The pattern: matrix calculation and downstream assignment in one prompt, so the routing model gets both inputs without a second operation.

Try It

Get the 7-day free trial of SheetXAI and open any Excel workbook with origin and destination coordinate data, then ask it to build a distance matrix using HERE. The HERE integration is included in every SheetXAI plan. See also how to calculate drive times from a fixed origin or the HERE in Excel overview.

Stop memorizing formulas.
Tell your spreadsheet what to do.

Join 4,000+ professionals saving hours every week with SheetXAI.

Learn more