Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

12
1222
213212
32
3231
3213131

The above codes should read as follows:

00000012
00001222
00213212
00000032
00003231
03213131

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.

1 Answer 1

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:

00000000 

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.