Excel: Add leading zeroes to a number

I wanted to add leading zeroes to a number column, making a seven-digit number. I found the REPT function:

=IF(LEN(A2)>7,A2,REPT("0",7-LEN(A2))&A2)

If the cell is longer than 7 digits, it puts the whole cell value in. If it is 7 or less, it will “repeat” the zero the required number of times.

Hope this helps 🙂