Cells in CSV file not retaining formatting

WLHagen

Board Regular
Joined
Sep 18, 2009
Messages
177
I have some data in CSV files that I need to import in to another program. Column A in the file contains the location of where the data in subsequent columns is mapped in the software. The locations in this software contain both numbers and letters, so I've formatted column A as TEXT. However, when I save the file, close it, and reopen the file, the formatting reverts to what Excel thinks I want. The cells in column A that I have difficulty with are cells that contain a leading zero or an E in it. For example:

084 - reverts to 84
085 - reverts to 85
065E1 - reverts to 65E1

TIA for any help!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
If you open the file in a text editor, such as notepad, do the leading zeros exist?
 
Upvote 0
In that case the original file did not have leading zeros, perhaps the cells had a custom format, before being saved as a csv
 
Upvote 0
Thanks. Since I created the file in Excel and didn't pay attention to formatting until after I had these errors in the csv version of the file, what is the solution?
 
Upvote 0
You will need to ensure that the cells are text & have a leading zero, rather than simply formatted to show a leading zero. That way when you save to csv the leading zeros should be retained.
 
Upvote 0
Simply formatting the cells should be sufficient. Excel creates CSV files using the displayed values.
 
Upvote 0
Never knew that Rory, thanks. :)
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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