Function Problems

Return Related ZIP Codes and Data Automatically in Excel

Kushani NimanthikaKushani Nimanthika Nov 18, 2026 868 views

Question details

Return neighboring ZIP codes for a selected primary ZIP code along with their associated demographic and housing data.

How to Return Related ZIP Codes and Data in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains relationships between primary ZIP codes and neighboring ZIP codes, plus a separate table of ZIP-code attributes.
Observed behavior
The desired result is a list that updates when the selected primary ZIP code changes and displays data for each related ZIP code.
Before you start

Define which ZIP codes are neighbors in a source table; formulas cannot determine those relationships on their own. Store ZIP codes consistently as text, including leading zeros, in both source tables and the input cell.

Solution 1Recommended

Use FILTER and XLOOKUP to return related ZIP codes and attributes

Use this method in an Excel version that supports dynamic arrays, FILTER, and XLOOKUP.

Set up one row per relationship in a table named Relationships, with columns named Primary ZIP and Neighbor ZIP. Create a separate table named ZIPData with one row per ZIP code and columns such as ZIP, Population, Income, and Housing.

1
Enter a primary ZIP code

On a summary sheet, format cell B1 as Text and enter the primary ZIP code you want to look up.

2
Return neighboring ZIP codes

In cell A3, enter =FILTER(Relationships[Neighbor ZIP],Relationships[Primary ZIP]=B1,"No matches"). The results spill into the cells below A3.

3
Return population data

In cell B3, enter =XLOOKUP(A3#,ZIPData[ZIP],ZIPData[Population],"Not found"). This looks up population for each ZIP code in the spilled list.

4
Add other attributes

In C3 and D3, use the same XLOOKUP formula but replace ZIPData[Population] with ZIPData[Income] and ZIPData[Housing], respectively. Leave the cells below the formulas clear so the results can spill.

Use FILTER and XLOOKUP to return related ZIP codes and attributes
Check missing results: If FILTER displays No matches, add or correct the relationship in the Relationships table. If XLOOKUP displays Not found, check that the neighboring ZIP code exists in ZIPData and uses the same text format.
Work with ZIP-code data in WPS

Look up neighboring ZIP-code data in WPS Spreadsheet

Use a relationship list, a filter, and VLOOKUP in WPS Spreadsheet to find the neighbors of a selected ZIP code and display their attributes.

  1. 1. Open the workbook: Open your Excel workbook in WPS Spreadsheet. Make sure the relationship sheet has Primary ZIP in column A and Neighbor ZIP in column B, with headers in row 1.
  2. 2. Prepare the data sheet: On a sheet named ZIPData, place ZIP codes in column A, population in B, income in C, and housing data in D. Store ZIP codes as text in both sheets.
  3. 3. Add attribute formulas: On the relationship sheet, enter =IFERROR(VLOOKUP(B2,ZIPData!$A$2:$D$1000,2,FALSE),"Not found") in C2 and fill it down. For income and housing, use the same formula in D2 and E2, changing the column index from 2 to 3 and 4.
  4. 4. Filter for the primary ZIP code: Select the relationship table, choose Data > Filter, and use the Primary ZIP header dropdown to select the ZIP code. The visible rows show its neighboring ZIP codes and their looked-up attributes.
Filter a relationship list by primary ZIP codeUse VLOOKUP to add population, income, and housing dataOpen and save Microsoft Excel XLSX filesWork in a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

How does Excel know which ZIP codes are neighbors?

It does not determine that relationship automatically. Add each primary ZIP and neighbor ZIP pair to the Relationships table before using FILTER.

Why does my ZIP code lookup return no matches?

Check that the relationship exists and that the input and source ZIP codes use the same text format. A numeric ZIP code and a text ZIP code may not match, especially when leading zeros are involved.

What does a spill error mean in the FILTER result?

The formula needs empty cells for its results. Clear any content blocking the spill range below the FILTER formula and try again.

Can I return more than population for each neighbor?

Yes. Add separate XLOOKUP formulas for columns such as Income and Housing, changing the return column while keeping ZIPData[ZIP] as the lookup column.

What if my Excel version does not support FILTER or XLOOKUP?

Filter the Primary ZIP column using Data > Filter, then use VLOOKUP to retrieve attributes for the visible neighbor ZIP codes. The list will need to be filtered again when you select a different primary ZIP.