Function Problems

Create an Excel Encoding Formula for Codes Like 12-05-NK

Chanuka GeekiyanageChanuka Geekiyanage Nov 12, 2026 868 views

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.

Create an Excel Encoding Formula for Codes Like 12-05-NK
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.
Before you start

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.

Solution 1Recommended

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.

1
Create the encoding lookup table

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.

2
Enter the split-and-lookup formula

Select the result cell, such as B2, and enter: =TEXTJOIN("-",TRUE,XLOOKUP(TEXTSPLIT(A2,"-"),$F$2:$F$20,$G$2:$G$20,"Not found"))

3
Review the encoded output

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.

4
Fill the formula down

Drag the fill handle from B2 down the column to encode additional codes entered in column A.

Split the code and encode each part with TEXTSPLIT and XLOOKUP
Encoding rules determine the final formula: A formula can extract and join the code parts, but the exact encoded output depends on the mapping rules for values such as 12, 05, and NK.
Encode Hyphenated Codes in WPS Spreadsheets

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. 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. 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. 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. 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. 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.
Extract code sections separated by hyphens with text formulas such as LEFT, MID, RIGHT, and FIND.Build a reusable lookup table for numeric and letter code mappings.Open and edit Microsoft Excel .xlsx and .xls workbook files with format compatibility.Use a familiar spreadsheet layout to review source parts and encoded results side by side.
microsoft office alternative - wps office

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.