Extract and Format ID Number Digits with an Excel Formula
Question details
Extract the first six digits of a 13-digit South African identification number and insert hyphens after the second and fourth digits.

- 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.
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.
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.
In Excel, select cell A1, choose Home > Number Format > Text, and enter the dummy value 0001011234567.
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.
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.

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. Open a spreadsheet: Open WPS Spreadsheet and create a blank workbook or open an existing Excel file.
- 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. Apply the formula: Select B1 and enter =LEFT(A1,2)&"-"&MID(A1,3,2)&"-"&MID(A1,5,2), then press Enter.
- 4. Check and extend the formula: Confirm that B1 displays 00-01-01, then drag its fill handle down to format other rows.

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.




