The TEXT function can apply number formats of any kind to numbers. It is most often used when you want to maintain number formatting for a number when concatenating that number with other text.
In this case, the TEXT function is used to apply a number format that consists only of zeros: "00000", "000000", "0000000", etc. These number formats automatically format a number by adding zeros to the left as needed to reach the total number of zeros supplied.
Note: padding a number with zeros this way changes the number into text, which may or may not suit your needs. To simply display a number with padding, see below.
Pad for display only
To pad a number with zeros for display only, just select the cell(s) and apply a custom number format like so:
Format cells > Number > Custom > "00000"
With this approach, the number is not converted to text, but remains a true number.
Pad with a variable number of zeros
If you want to pad a number with text using a variable number of zeros, you can add the REPT function inside TEXT like this:
The TEXT function can apply number formats of any kind, including currency, date, percentage, etc. By applying a number format like "00", "000", "0000", you can "pad" numbers with as many zeros as you like. Zeros will only be added where needed...
The Excel REPT function repeats characters a given number of times. For example, =REPT("x",5) returns "xxxxx".
Excel Formula Training
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.