How to Create an Excel Document Number with Leading Zeros
Question details
The user needs an Excel formula to combine fixed text, a dynamic string from a cell, and a sequential number formatted with leading zeros into a single document number string.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Generating structured document numbers or custom IDs (such as MRC-AMP-0001) by combining values located in separate cells.
- Observed behavior
- When combining separate cells, Excel naturally drops the leading zeros from sequential numbers unless explicitly instructed to retain a specific number format.
Ensure your document type codes and sequence numbers are organized in separate columns, and verify that the sequence values are entered as standard numbers before applying the concatenation formula.
Use the Ampersand (&) Operator and TEXT Function
The most efficient way to combine text and numbers while preserving leading zeros is to use the ampersand operator alongside the TEXT function to dictate the exact digit format.
The ampersand (&) operator links multiple strings and cell values together, while the TEXT function ensures the numeric sequence retains a fixed length by adding leading zeros where necessary.
Click on the cell where you want the final combined document number to appear, such as C2.
Type the formula ="MRC-"&A2&"-"&TEXT(B2,"0000") directly into the cell or the formula bar, assuming A2 holds the document type and B2 holds the sequence number.
Press Enter to generate the first document number, then click and drag the fill handle at the bottom-right corner of the cell down the column to automatically format the remaining rows.

Use the CONCATENATE Function
If you prefer using formal text functions over operators, you can nest the TEXT function inside a CONCATENATE (or CONCAT) function to achieve the same result.
Generate Document Numbers Effortlessly with WPS Spreadsheet
WPS Spreadsheet fully supports advanced text operations and the TEXT function, allowing you to dynamically create custom document numbers, product codes, and IDs just like you would in Microsoft Excel.
- 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open the workbook containing your document codes and sequence numbers.
- 2. Input the text formatting formula: Select the cell for your final output and type the formula: ="MRC-"&A2&"-"&TEXT(B2,"0000").
- 3. Confirm the result: Press Enter to view the combined text, ensuring the leading zeros are correctly preserved.
- 4. Drag to apply to other cells: Use the fill handle at the bottom right of the cell to drag the formula down, instantly generating document numbers for your entire list.

Frequently Asked Questions
Why do leading zeros disappear when I type them into a spreadsheet?
By default, spreadsheets treat standard numerical entries as mathematical values, dropping leading zeros since they do not change the number's actual value. To keep them, you must format the cell as Text before typing, use an apostrophe (') before the number, or format it using the TEXT function.
Can I adjust the formula to create a six-digit sequence instead of four?
Yes. To change the total number of digits, simply adjust the number of zeros in the quotation marks within the TEXT function. For a six-digit sequence, change TEXT(B2, "0000") to TEXT(B2, "000000").
How do I use spaces instead of hyphens in my document number?
You can replace the hyphens within the quotation marks with spaces. For example, your modified formula would look like this: ="MRC "&A2&" "&TEXT(B2, "0000"). Make sure the space is enclosed between the quotation marks.




