How to Add Leading Zeros to Numbers in Excel
Restore lost leading zeros on IDs and ZIP codes and build fixed-width order numbers like ORD-000042 with formulas.
You will learn to
- Pad a number to a fixed width with TEXT
- Fix ZIP codes that lost their leading zero
- Build prefixed, zero-padded order numbers
How it works
Excel treats 02134 as the number 2134 and silently drops the zero — a classic problem with ZIP codes, employee IDs and account numbers. =TEXT(A2,"000000") pads a number with zeros to six digits: 4187 becomes "004187". Each 0 in the format code is a digit that will always be shown.
An alternative that also works on text is =RIGHT("00000"&B2,5): add more zeros than you need, then keep the rightmost five characters. Both formulas return text, which is what you want for identifiers. Combine with & for prefixed codes: ="ORD-"&TEXT(C2,"000000").
=TEXT(A2,"000000")