ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a .csv file that will import to multiple worksheets (https://www.excelbanter.com/excel-programming/380423-re-creating-csv-file-will-import-multiple-worksheets.html)

NickHK

Creating a .csv file that will import to multiple worksheets
 
If you are asking if Excel can do this on it own, then the answer is No:
Excel expects all data in a such file to be in the same format and will
import to single worksheet. You can of course cut/paste (either manually or
in code) to produce the desired result.

Otherwise you will need to Open the file (check the VBA help for the Open
Statement), read a line and decide which file you are in from the header
info, then read line by line, unless the header tells you how many
lines/bytes you need to deal with.

If you can get the output file correctly formatted in Excel's version of
..csv, Excel can open .csv file directly, so no need for the steps.

NickHK

"mastermind" wrote in message
...
I have the following workflow:

1. An application program is creating several .csv files which have
header information on the 1st line and data on the subsequent lines.

There
are approximately 4 of these files.
2. In Excel, the users open each .csv file separately and go through
the format prompt to display the contents in a worksheet.

Question - can I create single CSV file that contains all 4 files(with
different column formats) that can be imported into Excel as separate
worksheets?

Thx.




NickHK

Creating a .csv file that will import to multiple worksheets
 
I meant that if you can the output csv files in the format that Excel
expects for csv files, there would be no need for the user to go through the
wizard as they would open directly in Excel as a worksheet.

NickHK

"mastermind" wrote in message
...
Thx. This is what I had thought, that the only way to do this would be if
the user had a pre-written macro that would parse the combined file

creating
separate worksheets.

I am curious as to your last statement about getting it into the 'correct'
csv format of Excel - how could I determine this format? Would I save a
workbook with multiple sheets as a csv? I thought that the csv export is

by
worksheet only.

Any help would be appreciated.

"NickHK" wrote:

If you are asking if Excel can do this on it own, then the answer is No:
Excel expects all data in a such file to be in the same format and will
import to single worksheet. You can of course cut/paste (either manually

or
in code) to produce the desired result.

Otherwise you will need to Open the file (check the VBA help for the

Open
Statement), read a line and decide which file you are in from the header
info, then read line by line, unless the header tells you how many
lines/bytes you need to deal with.

If you can get the output file correctly formatted in Excel's version of
..csv, Excel can open .csv file directly, so no need for the steps.

NickHK

"mastermind" wrote in message
...
I have the following workflow:

1. An application program is creating several .csv files which

have
header information on the 1st line and data on the subsequent lines.

There
are approximately 4 of these files.
2. In Excel, the users open each .csv file separately and go

through
the format prompt to display the contents in a worksheet.

Question - can I create single CSV file that contains all 4

files(with
different column formats) that can be imported into Excel as separate
worksheets?

Thx.








All times are GMT +1. The time now is 03:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com