Leading Zeros

rexel12

Board Regular
Joined
Feb 19, 2002
Messages
86
I currently import a csv file. One of the columns contains some numbers that have four leading zeros and also some numbers that have a leading alphabetic character. When the csv is imported it drops the leading zeros. If I use the custom format it adds zeros to everything in the column. Is there any way to add zeros back to a cell containing less than 6 characters?

TIA
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
There's a couple of ways:

Firstly when you go through the import wizard you will have an opportunity to tell the wizard the kind of cell you are importing, at this stage you change it from "General" to "Text". That way you keep all leading Zeros on the columns you selected.

The second way is by using "0" instead of "#" in the custom mode of formating cells.

Mark
 
Upvote 0
On 2002-04-11 01:13, rexel12 wrote:
I currently import a csv file. One of the columns contains some numbers that have four leading zeros and also some numbers that have a leading alphabetic character. When the csv is imported it drops the leading zeros. If I use the custom format it adds zeros to everything in the column. Is there any way to add zeros back to a cell containing less than 6 characters?

TIA

Use

=RIGHT(REPT("0",6-LEN(A1))&A1,6)

if multiple leading zeroes are missing or

=RIGHT(0&A1,6)

if just a single leading zero is missing.
 
Upvote 0
On 2002-04-11 01:13, rexel12 wrote:
I currently import a csv file. One of the columns contains some numbers that have four leading zeros and also some numbers that have a leading alphabetic character. When the csv is imported it drops the leading zeros. If I use the custom format it adds zeros to everything in the column. Is there any way to add zeros back to a cell containing less than 6 characters?

TIA

Change the file extension to .txt and use the Text to Columns wizard.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top