Function Problems

How to Replace Municipality Names with Districts Using an Excel Lookup Formula

Adam DavisAdam Davis Nov 13, 2026 869 views

Question details

The user needs a lookup formula to automatically return the district associated with each municipality from a mapping table on another worksheet.

How to Replace Municipality Names with Districts Using an Excel Lookup Formula
Product
WPS Office Spreadsheets
Device & OS
not provided
Scenario
The user has a list of municipality names and a separate lookup table that maps each municipality to its district, and wants to fill the district column automatically.
Observed behavior
The district should appear automatically for each municipality based on the municipality-to-district lookup table.
Before you start

Make sure the municipality list and the lookup table are in the same workbook, and that the municipality names are spelled identically in both locations. Check whether your WPS Office or Excel version supports XLOOKUP so you can choose the simplest formula.

Solution 1Recommended

Use XLOOKUP to Return the District for Each Municipality

Best for Microsoft 365 and current WPS Office versions that support XLOOKUP; it returns exact matches and can show a custom not-found message.

XLOOKUP searches for a lookup value in one column and returns the result from another column in the same row. It is more flexible than VLOOKUP because the return column can be on either side and you can specify a value to show when no match is found.

1
Select the district cell

Click the cell where you want the district to appear, such as B2 next to the first municipality name.

2
Enter the XLOOKUP formula

Type =XLOOKUP(A2,LookupTable[Municipality],LookupTable[District],"Not found") and press Enter. Replace A2 with the first municipality cell and the table and column references with your workbook references.

3
Fill the formula down

Drag the fill handle from the formula cell down through all municipality rows to apply the lookup to the entire list.

Result: Each municipality now shows its matching district, or "Not found" when no match exists.

Replace Municipality Names with Districts in WPS Office Spreadsheets

WPS Office Spreadsheets supports XLOOKUP, VLOOKUP, and INDEX and MATCH, so you can create a lookup formula that automatically returns each municipality's district from a separate mapping table.

  1. 1. Download and install WPS Office: Go to the WPS Office download page, download the free installer, and sign in with your WPS account.
  2. 2. Open your workbook in WPS Spreadsheets: Click Menu > Open, select your .xlsx file, and go to the worksheet containing the municipality list.
  3. 3. Create the lookup formula: Click the district cell, type =XLOOKUP(A2,LookupTable[Municipality],LookupTable[District],"Not found") or a VLOOKUP equivalent, and press Enter.
  4. 4. Fill the formula down: Drag the fill handle down the column to apply the district lookup to all municipalities.
  5. 5. Save and share: Click Menu > Save As and choose .xlsx to keep full Excel compatibility.
Use familiar Excel-compatible lookup formulas such as XLOOKUP and VLOOKUPAutomatically fill district names from a municipality-district mapping tableOpen and save .xlsx workbooks with full Microsoft Excel format compatibilityFree, lightweight Office suite with a familiar spreadsheet interfaceReduce manual retyping and data entry errors
microsoft office alternative - wps office

Frequently Asked Questions

Which lookup formula should I use if XLOOKUP is not available?

Use VLOOKUP or INDEX and MATCH. If your Excel or WPS version does not support XLOOKUP, enter =VLOOKUP(A2,LookupTable!A:B,2,FALSE) or =INDEX(LookupTable!B:B,MATCH(A2,LookupTable!A:A,0)).

How do I reference a lookup table on another worksheet?

Use the sheet name followed by an exclamation mark, or use a structured table reference. For example, use LookupTable[Municipality] and LookupTable[District], or if the sheet is named Districts, use Districts!A:B.

What does the "Not found" value do in XLOOKUP?

It is the value returned when the municipality is not present in the lookup table. You can change it to "Missing", a blank value, or any other custom text.

Why does my VLOOKUP return #N/A?

This usually happens because the municipality text has extra spaces, different capitalization, or the lookup column is not the first column in the VLOOKUP table range. Clean the values or use FALSE for an exact match.

Can I use this method to replace other names or codes in Excel?

Yes. The same lookup formula works for any one-to-one mapping, such as product codes to product names or cities to regions, as long as the lookup column contains unique values.