Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: File Formats that Include Field Formats.

File Formats that Include Field Formats

by Allen Wyatt
(last updated December 26, 2015)

3

Wolfgang often imports CSV files that are created by other programs. When importing, he needs to specify how Excel should treat the incoming data. This causes Wolfgang to wonder if there is a file format that Excel can import that has field formats embedded so that he doesn't have to do any manual work on import.

The short answer is no, there isn't such a format. Technically you can create an XML-formatted file that uses the format of Office, and it can specify what the field formats should be. Such a file consists of only text (like a traditional CSV file) and includes specifiers about how the data should be formatted. (Complete details on how such an XML file should be structured is beyond the scope of this tip.)

Such an endeavor is undeniably daunting to many people, so you could also simply import your CSV file with no formatting applied, and then use the macro recorder to record how you manually format the freshly imported data. This macro could then be executed every time you import another file that uses the same sort of data as the first CSV file you imported.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11602) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: File Formats that Include Field Formats.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Multiple Users Using a Word Document

Want to collaborate with others on creating your literary masterpiece? It may be easier than you think, depending on the ...

Discover More

Adding Half Spaces to Punctuation

Want a little more space just before some of your punctuation characters? You can add that spacing in a variety of ways, as ...

Discover More

Two Page Numbering Schemes in the Same Document

Word is great at numbering pages if you only need a single, consistent numbering scheme through the document. If you need two ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Determining the Length of a Text File

When processing plain text files in a macro, it is often helpful to know how much data the file contains. The normal way to ...

Discover More

Full Path to Workbook

Need to get the full path of your current workbook into the Clipboard? Excel doesn't make it quite as easy as it used to be, ...

Discover More

Adding a File Path and Filename

If you need to stuff the current workbook's filename and path into a cell or a header or footer, you'll appreciate the ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 2?

2016-01-04 12:21:55

Steve Adams

Anne's suggestion works very well for me as well.

But for new files being imported for the first time, I have had some success in change the file extension of the CSV file to .TXT

Then open Excel first and then use the file open commands to locate the .TXT file (you will have to change the file type drop down from "All Excel Files..." to "Text Files..."

The Text Import Wizard will start automatically when opening a .TXT file.

On Step 1 select "Delimited"
If your file has page header text, you may need to select a starting row for the import (either your column header row if one exists or the first data row).

On Step 2 Select "Comma" for the delimiter (assuming you did start with a .CSV file).

On step 3 you can click on the various columns and identify some basic formats (General, Text, or Date) or to skip a column. If you have an identifying number that exceeds Excel's number place values (15 digits), select text for that column to prevent truncation (or to preserve leading zeros). Also, dates sometimes come across as text if you don't select the Date format.


2015-12-28 11:00:06

Anne

Further to my comment, I should specify to copy and paste VALUES, of course.


2015-12-28 10:11:35

Anne

I spend my days working with CSV and SAP files. I use them to create reports or gather information for reports. What I've done is create an excel spreadsheet formatted to my specifications, using the CSV data, initially. (I often use Excel Tables, as they maintain the formatting even when data is added below the last row.) I then copy and paste the data from the CSV file to the formatted spreadsheet - omitting the column headers as they would already exist in the formatting spreadsheet from previous reports. The CSV data automatically take on the formatting of the existing spreadsheet. For instance, the SAP file I use repeatedly have lots of numbers with leading zeros - like so - 00000000240. When I drop this into my formatted spreadsheet, it appears at 240, with no additional manipulation needed. Magic!


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.