CDXDistance Function
Previous  Top  Next


For a general overview of how to insert data and functions into your worksheet, please refer to the topic Inserting Data and Functions.

The CDXDistance custom function calculates straight line ("as the crow flies") distances between ZIP Codes. It can be employed as a right-click function as well as input directly into your worksheet as a custom function formula. (Please also refer to the help section on custom functions.) To calculate driving distances and times, please use the CDXRouteMP or CDXRouteBing function.

This function will work with Canadian postal codes, if you have purchased the Canadian data option.

To use as a right-click function, right-click on any cell in a worksheet, select the Insert CDXDistance Function, and you will see the interface shown below:

clip0353

Input either the actual ZIP or postal code, or their cell address locations in the worksheet. Use cell addresses if you plan to apply the function to other ZIP Code pairs in the worksheet. Also, you can specify the output to be returned in miles, kilometers, or nautical miles.

clip0354

In this case the first pair of ZIP Codes are in cells B4 and C4, and the custom function formula is:

=CDXDistance(B4, C4)

This formula can also be input directly to the worksheet cell if desired.

The result is a calculated distance of about 473 miles.

To apply this to the remaining ZIP Codes, copy and paste the custom function formula. In this case, we copy cell D4 and paste it to the range D5 through D13:

clip0355

This cut and paste technique will also work if the ZIP Codes are listed in rows instead of columns as shown here.

The calculated distance is automatically provided in miles, but you can specify kilometers or nautical miles as shown in the following examples:

For kilometers: = CDXDistance(B4, C4, "KM")
For nautical miles: = CDXDistance(B4, C4, "NM")