How to Keep Leading Zeros in CSV File Format?

KJKirkland

New Member
Joined
Nov 23, 2019
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello!

I am trying to have a column of numbers include leading zeros so they all contain six digits.

Scenario

1. I want all numbers in the first column to have six digits (if they already have 5 digits, add 1 leading zero, 4 digits = 2 leading zeroes, and so on).
2. When I follow a website I found with tips for this process (highlight cells, format cells, category - custom, type 6 0's under type, click OK) - the format of the cell automatically changes to "Special", not custom).
3. Then, when I close the file and re-open it, the numbers are back to the original digits (4 or 2 or whatever) and not the 6 digits with the leading zeros.

Thank you for any help you can provide!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
After you import the CSV and apply your formatting you need to save the file as xlsx. CSVs strip out formatting and pretty much everything except for the data.
 
Upvote 0
Welcome to the MrExcel board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules. Be sure to follow & read the link at the end of the rule too!

If you do cross-post in the future and also provide a link, then there shouldn’t be a problem.
 
Upvote 0
@KJKirkland
Just put '0xxxx at the starting of the number and then save the file to .csv, the numbers will start with leading 0
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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