Function Problems

Convert Alphabetic Codes to Numeric Codes in Excel

Amos GikundaAmos Gikunda Nov 18, 2026 869 views

Question details

Convert alphabetic codes into corresponding six-digit numeric codes using a reference table and an Excel formula.

Convert Alphabetic Codes to Numeric Codes in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains alphabetic codes such as A, W, and SE that need to be matched to predefined numeric codes.
Observed behavior
Each alphabetic code should return its corresponding six-digit code from a mapping table.
Before you start

Gather the correct numeric equivalent for each alphabetic code. Decide whether codes with leading zeros should be stored as text or displayed with a six-digit number format.

Solution 1Recommended

Use VLOOKUP with a code mapping table in Excel

Use an exact-match lookup to return the numeric code associated with each alphabetic code.

1
Create the mapping table

Enter the alphabetic codes in F3:F7 and their corresponding numeric codes in G3:G7. Use your own code mappings.

2
Enter the lookup formula

With the source code in A3, select the cell where you want the result and enter =VLOOKUP(A3,$F$3:$G$7,2,FALSE).

3
Copy the formula

Drag the result cell's fill handle down to look up additional codes in column A. The dollar signs keep the mapping range fixed.

4
Display six digits

If the returned codes are numbers that need leading zeros, select the result cells, open Format Cells, and choose Custom with the format 000000.

Use VLOOKUP with a code mapping table in Excel
Check missing matches: The formula returns #N/A if a code is not found. Check the spelling and remove extra spaces in the source and mapping cells.
Use WPS Spreadsheets

Map alphabetic codes with VLOOKUP in WPS Spreadsheets

Create a two-column reference table in WPS Spreadsheets and use VLOOKUP to return the numeric code for each alphabetic code.

  1. 1. Open the worksheet: Open WPS Spreadsheets and select Open to load your workbook.
  2. 2. Build the reference table: Enter alphabetic codes in F3:F7 and their corresponding numeric codes in G3:G7.
  3. 3. Add the formula: Select a result cell next to the code in A3 and enter =VLOOKUP(A3,$F$3:$G$7,2,FALSE).
  4. 4. Fill and format the results: Drag the fill handle down to copy the formula. For numeric results that need leading zeros, open Format Cells and apply the custom format 000000.
Convert alphabetic codes using an exact-match lookupOpen and edit Microsoft Excel XLSX filesApply a custom six-digit display formatUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does VLOOKUP return #N/A for a code?

The code may be missing from F3:F7 or contain extra spaces. Check both the source cell and the mapping table, and confirm that the formula uses FALSE for an exact match.

How can I keep leading zeros in a six-digit code?

For numeric results, select the result cells and use Format Cells > Custom with the format 000000. This changes the display, not the underlying number.

Can I use XLOOKUP instead of VLOOKUP?

In an Excel version that supports XLOOKUP, enter =XLOOKUP(A3,$F$3:$F$7,$G$3:$G$7,"Not found") to return the matching code or a message when no match exists.

What happens if the mapping table contains duplicate alphabetic codes?

VLOOKUP returns the value from the first matching row. Check F3:F7 for duplicates if each alphabetic code should have only one numeric equivalent.