Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How do you add zero before values in excel document?

I am trying to edit product codes in Excel so that each product code is exactly 8 digits in length.

Currently the product codes are different lengths, for example:


The above codes should read as follows:


As you can see all product codes are now 8 digits in length, any product codes that were less than 8 have had the correct number of 0's prepended to them.

Any help with an Excel formula that would magically do this for me would be appreciated!

share|improve this question

marked as duplicate by random Sep 1 '11 at 13:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 3 down vote accepted

Format the cells with a custom format to always use at least eight digits, so the format would be:


The Microsoft article Using a custom number format to display leading zeros provides more information that you might find useful.

The same method works in LibreOffice.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.