Adding a leading zero "0" to a number in a cell

C

chipwood3

I am trying to create a formula that will add a leading zerto to any number
that comes in with less than 5 digits. This is for a spreadsheet that will
carry over zip codes for a mailing. I want to know if I can write a formula
and if so, what it is that if a column of numbers just has 234 that the
formula will automatically add the two zeros making it 00234. Or if it is
2345 it will convert it to 02345.

Also - will the leading zeros (for lack of a better term) be hard coded so
that when you extor to a csv or another format, the zeros will remain.

Thanks
 
B

B Lynn B

supposing your 234 value is in cell A1, your formula would be:
=TEXT(A1,"00000")

Yes, these will be sustained through saving as CSV or other format, as they
are now a text value.
 
O

OssieMac

Select Number format then Number then Custom. Inset 5 zeros in the Type: Field.

I tested this in xl2007. Saving as a .csv file and then opened it with
Notepad and the leading zeros were there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top