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 🙂

Updated: Wednesday, 28th November, 2018 — 10:16 am

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.