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

Saving and Using a Form

After you have created your custom form, you will need to save it so that you can use it as often as needed. Word makes ...

Discover More

Pasting a Graphic to Multiple Worksheets

Do you need to add a logo or other graphic to a bunch of worksheets? Here are a couple of short macros that can make ...

Discover More

Random Width and Height Changes

Have you ever been using a workbook, only to open it one day and find that Excel has changed the height of your rows or ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Invalid Names when Opening Workbook

Don't you hate opening a workbook and seeing error messages? If you see a message that some "invalid names" were detected ...

Discover More

Loading Unwanted Files at Startup

Imagine how painful it would be if every time you started Excel it tried to load all the files in your root directory? ...

Discover More

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 ...

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 three less than 4?

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.