Convert Alphabetic Codes to Numeric Codes in Excel
Question details
Convert alphabetic codes into corresponding six-digit numeric codes using a reference table and an Excel formula.

- 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.
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.
Use VLOOKUP with a code mapping table in Excel
Use an exact-match lookup to return the numeric code associated with each alphabetic code.
Enter the alphabetic codes in F3:F7 and their corresponding numeric codes in G3:G7. Use your own code mappings.
With the source code in A3, select the cell where you want the result and enter =VLOOKUP(A3,$F$3:$G$7,2,FALSE).
Drag the result cell's fill handle down to look up additional codes in column A. The dollar signs keep the mapping range fixed.
If the returned codes are numbers that need leading zeros, select the result cells, open Format Cells, and choose Custom with the format 000000.

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. Open the worksheet: Open WPS Spreadsheets and select Open to load your workbook.
- 2. Build the reference table: Enter alphabetic codes in F3:F7 and their corresponding numeric codes in G3:G7.
- 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. 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.

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.




