Function Problems

Extract and Format ID Number Digits with an Excel Formula

Aamir Naveed AkramAamir Naveed Akram Nov 13, 2026 872 views

Question details

Extract the first six digits of a 13-digit South African identification number and insert hyphens after the second and fourth digits.

Extract and Format ID Number Digits with an Excel Formula
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains identification numbers, and the user wants to display the first six digits in a two-digit, two-digit, two-digit format.
Observed behavior
The desired result is a text value such as 00-01-01 for an ID number beginning with 000101.
Before you start

Make sure the ID number is stored as text so that any leading zero is preserved. Use dummy identification numbers when testing or sharing a workbook.

Solution 1Recommended

Use LEFT and MID to format the first six ID digits

Use this formula when the complete ID number is stored in a cell and you need the first six digits separated by hyphens.

1
Enter a dummy ID as text

In Excel, select cell A1, choose Home > Number Format > Text, and enter the dummy value 0001011234567.

2
Enter the formula

Select cell B1 and enter =LEFT(A1,2)&"-"&MID(A1,3,2)&"-"&MID(A1,5,2). Replace A1 with the cell containing your ID number if needed.

3
Check and copy the result

Press Enter and check that the dummy value returns 00-01-01. Drag the fill handle down from B1 to apply the formula to additional rows.

Use LEFT and MID to format the first six ID digits
Leading zeros and validation: If a leading zero was lost when the ID was entered as a number, re-enter the complete value as text before using the formula. The formula formats characters; it does not validate the ID or its date.
Format ID digits in WPS Spreadsheet

Format ID Number Digits in WPS Spreadsheet

Use the same LEFT and MID formula in WPS Spreadsheet to extract the first six ID digits and separate them with hyphens.

  1. 1. Open a spreadsheet: Open WPS Spreadsheet and create a blank workbook or open an existing Excel file.
  2. 2. Enter a test ID as text: Select A1, choose the Text number format on the Home tab, and enter the dummy value 0001011234567.
  3. 3. Apply the formula: Select B1 and enter =LEFT(A1,2)&"-"&MID(A1,3,2)&"-"&MID(A1,5,2), then press Enter.
  4. 4. Check and extend the formula: Confirm that B1 displays 00-01-01, then drag its fill handle down to format other rows.
Format the first six ID digits with a reusable formula.Open and edit Microsoft Excel XLSX and XLS files.Use a familiar spreadsheet interface for formulas and cell formatting.Copy the formula down a column for multiple rows.
microsoft office alternative - wps office

Frequently Asked Questions

What does the formula return for an ID beginning with 000101?

If the complete ID is stored as text in A1, the formula returns 00-01-01 in the cell where you enter it.

Why is the first zero missing from my result?

Excel may have removed the leading zero when the ID was entered as a number. Select the source cell, set Home > Number Format to Text, and re-enter the complete ID.

Can I apply the formula to a whole column?

Enter the formula in the first result cell, such as B1, and drag the fill handle down. The A1 reference adjusts for each row.

Does this formula check whether the ID number is valid?

No. LEFT and MID extract and format the first six characters; they do not check the ID length, date, or validity.