Create an Excel Encoding Formula for Codes Like 12-05-NK
Question details
Create a worksheet formula that separates a hyphenated code such as 12-05-NK, applies an encoding rule to each component, and returns one combined encoded result.

- Product
- Microsoft Excel worksheet formula
- Device & OS
- not provided
- Scenario
- The first two code elements can already be encoded, and the user needs to handle the remaining element or build a complete formula for all parts.
- Observed behavior
- The input code contains three variable components separated by hyphens, so each component must be extracted before its corresponding encoding can be applied.
Place each original code in one cell, such as A2, and create a lookup table that lists every source value and its required encoded value. Confirm whether leading zeros, such as 05, must remain text values in the encoded result.
Split the code and encode each part with TEXTSPLIT and XLOOKUP
Use this approach when your Excel version supports TEXTSPLIT, XLOOKUP, and TEXTJOIN and your encoding rules are stored in a lookup table.
For a code in A2, TEXTSPLIT separates 12-05-NK into three values. XLOOKUP then finds the encoded replacement for each value in the lookup table, and TEXTJOIN combines the replacements into one result.
For example, create a lookup table with source values in F2:F20 and encoded values in G2:G20. Adjust the output separator in TEXTJOIN to match your required encoded format.
In the worksheet, enter the original code components in column F and their encoded equivalents in column G. For example, enter 12, 05, and NK in F2:F4, with their required encoded values in G2:G4.
Select the result cell, such as B2, and enter: =TEXTJOIN("-",TRUE,XLOOKUP(TEXTSPLIT(A2,"-"),$F$2:$F$20,$G$2:$G$20,"Not found"))
Press Enter and verify that every component in A2 has a matching entry in the F:G lookup table. If a component is missing, the formula returns Not found for that part.
Drag the fill handle from B2 down the column to encode additional codes entered in column A.

Extract the three code parts with MID and FIND for older Excel versions
Use this method when TEXTSPLIT is unavailable or when you prefer helper columns that make each extracted component easy to review.
Split and Encode Codes Like 12-05-NK in WPS Spreadsheets
WPS Spreadsheets lets you separate hyphen-delimited code values with worksheet formulas, map each part through an encoding table, and combine the results in a single output column. Its familiar spreadsheet interface makes it easy to test formulas on sample codes and fill them down for larger lists.
- 1. Enter source codes in a column: Open WPS Spreadsheets and place codes such as 12-05-NK in column A, beginning with cell A2.
- 2. Add the encoding table: Enter each original component in one column, such as F, and its encoded replacement in the adjacent column, such as G.
- 3. Separate each code component: Use formulas in helper columns, such as =LEFT(A2,FIND("-",A2)-1), to extract the first component and corresponding MID and RIGHT formulas for the other components.
- 4. Look up the encoded values: Use the lookup formula available in your workbook, such as XLOOKUP or VLOOKUP, to return the mapped value for every extracted component.
- 5. Join the final encoded code: In the output cell, combine the encoded components with & or TEXTJOIN, then drag the formula down to process the remaining rows.

Frequently Asked Questions
How do I split 12-05-NK into separate cells in Excel?
If TEXTSPLIT is available, enter =TEXTSPLIT(A2,"-") to spill 12, 05, and NK into separate cells. Otherwise, use LEFT, MID, RIGHT, and FIND formulas in helper columns.
Why does the value 05 lose its leading zero after splitting the code?
Spreadsheet programs may treat 05 as the number 5. Format the lookup source column as Text before entering codes, or use TEXT with an appropriate format when the encoded result must preserve two digits.
Can I use one formula to encode every part of a hyphenated code?
Yes. With a source-to-encoded lookup table in F2:G20, a modern formula is =TEXTJOIN("-",TRUE,XLOOKUP(TEXTSPLIT(A2,"-"),$F$2:$F$20,$G$2:$G$20,"Not found")).
What should I do when the formula returns Not found for NK?
Check that NK appears exactly in the lookup source range, including capitalization and hidden spaces. Add NK and its required encoded value to the lookup table, then recalculate the formula.
Can WPS Spreadsheets open an Excel file that contains code-encoding formulas?
Yes. WPS Spreadsheets can open and edit common Excel .xlsx and .xls files. Review formulas after opening, especially newer Excel-only functions, and use helper-column text formulas if needed.




