Caution

If you try to record the process of opening a comma-delimited file where the filename ends in ,csv,Excel records the Workbooks.open method rather than workbooks.openText. If you need to control the formatting of certain columns, rename the file to have a .txt extension before recording the macro.

Figure 18.6

This file is comma delim-ited.Opening this file involves telling Excel to look for a comma as the delimiter and then identifying any special han-dling,such as treating the third column as a date.This is far easier than handling fixed-width files.

Figure 18.6

This file is comma delim-ited.Opening this file involves telling Excel to look for a comma as the delimiter and then identifying any special han-dling,such as treating the third column as a date.This is far easier than handling fixed-width files.

Turn on the macro recorder and record the process of opening the text file. In Step 1 of the wizard, specify that the file is Delimited.

In the Text Import Wizard—Step 2 of 3, the data preview may initially look horrible. This is because Excel defaults to assuming that each field is separated by a tab character (see Figure 18.7).

0 0

Post a comment