Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 109
Default Merging files

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 109
Default Merging files

I've been looking at Leith Ross's solution to a similar issue posted
yesterday which goes some way to answering my problem. However his solution
throws up formatting issues for me as two of the fields I wish to import are
date and time.

Look forward to any ideas,

Ian.


"Ian" wrote:

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merging files

You could open each of the 500 files and merge them together, but I think I'd
use an old DOS command to merge the data before it hits excel.

Shell to DOS
(windows start button|run
type this and hit enter:
cmd
(or
Command
for win98)

Go to that folder with the 500 .csv files.

Copy *.csv All.Txt
(don't use All.CSV)
now rename All.Txt to All.CSV

and import that all.csv file.

Ian wrote:

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 109
Default Merging files

Dave,

Excellent tip, worked a treat and just what I wanted without the programming
headache, thank goodness for DOS!

Cheers,
Ian.

"Dave Peterson" wrote:

You could open each of the 500 files and merge them together, but I think I'd
use an old DOS command to merge the data before it hits excel.

Shell to DOS
(windows start button|run
type this and hit enter:
cmd
(or
Command
for win98)

Go to that folder with the 500 .csv files.

Copy *.csv All.Txt
(don't use All.CSV)
now rename All.Txt to All.CSV

and import that all.csv file.

Ian wrote:

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merging files

You could even set up a small .bat file and run that if you need to do it again
(and again and again)...

And if you get industrious, you could call that .bat file within a VBA macro.

Ian wrote:

Dave,

Excellent tip, worked a treat and just what I wanted without the programming
headache, thank goodness for DOS!

Cheers,
Ian.

"Dave Peterson" wrote:

You could open each of the 500 files and merge them together, but I think I'd
use an old DOS command to merge the data before it hits excel.

Shell to DOS
(windows start button|run
type this and hit enter:
cmd
(or
Command
for win98)

Go to that folder with the 500 .csv files.

Copy *.csv All.Txt
(don't use All.CSV)
now rename All.Txt to All.CSV

and import that all.csv file.

Ian wrote:

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
Ian Ian is offline
external usenet poster
 
Posts: 109
Default Merging files

DAve,

Already done the .bat file as I will be repeating again and again! Not
thought about the macro though, is it fairly straightforward?

Cheers,
Ian.


"Dave Peterson" wrote:

You could even set up a small .bat file and run that if you need to do it again
(and again and again)...

And if you get industrious, you could call that .bat file within a VBA macro.

Ian wrote:

Dave,

Excellent tip, worked a treat and just what I wanted without the programming
headache, thank goodness for DOS!

Cheers,
Ian.

"Dave Peterson" wrote:

You could open each of the 500 files and merge them together, but I think I'd
use an old DOS command to merge the data before it hits excel.

Shell to DOS
(windows start button|run
type this and hit enter:
cmd
(or
Command
for win98)

Go to that folder with the 500 .csv files.

Copy *.csv All.Txt
(don't use All.CSV)
now rename All.Txt to All.CSV

and import that all.csv file.

Ian wrote:

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.

--

Dave Peterson


--

Dave Peterson

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merging files

Take a look at Shell in VBA's help to run that .bat file.

Ian wrote:

DAve,

Already done the .bat file as I will be repeating again and again! Not
thought about the macro though, is it fairly straightforward?

Cheers,
Ian.

"Dave Peterson" wrote:

You could even set up a small .bat file and run that if you need to do it again
(and again and again)...

And if you get industrious, you could call that .bat file within a VBA macro.

Ian wrote:

Dave,

Excellent tip, worked a treat and just what I wanted without the programming
headache, thank goodness for DOS!

Cheers,
Ian.

"Dave Peterson" wrote:

You could open each of the 500 files and merge them together, but I think I'd
use an old DOS command to merge the data before it hits excel.

Shell to DOS
(windows start button|run
type this and hit enter:
cmd
(or
Command
for win98)

Go to that folder with the 500 .csv files.

Copy *.csv All.Txt
(don't use All.CSV)
now rename All.Txt to All.CSV

and import that all.csv file.

Ian wrote:

I have a series of around 500 .csv files, stored in one defined directory,
which I would like to merge into one Excel spreadsheet. All the .csv files
have data in the same format but very in the number of rows of data they
contain, varying between one and ten rows of data.

Is possible to write a piece of code that will open each .csv file, in the
directory, in turn, determine the number of rows present, copy that number of
rows of data and then paste|append those rows into a master Excel worksheet?

Thanks for any pointers,
Ian.

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging 2 files Distribution list - Contacts Module Excel Discussion (Misc queries) 1 October 25th 08 02:48 AM
merging two files mcap Excel Discussion (Misc queries) 3 April 9th 06 07:28 PM
Merging files mac_see[_3_] Excel Programming 2 March 5th 05 02:09 AM
merging two files morry[_20_] Excel Programming 7 June 22nd 04 08:15 PM
Merging Files rglasunow[_13_] Excel Programming 3 February 3rd 04 01:27 AM


All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"