Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default looping through txt files and pasting into a excel worksheet

Can anyone help me create code to accomplish the following:

I have a folder that has a bunch of text files in it. I would like to
programatically open each file in a folder that contains the text '_MAST' in
it, copy the contents, and then paste it into an excel worksheet. I would
like it to keep looping through all of the text files in the folder until
all of the contents are pasted into one excel worksheet.

Any help would be greatly appreciated.

--
Regards,

timmulla
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default looping through txt files and pasting into a excel worksheet

Hi timmulla

Try the example on this page
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Can anyone help me create code to accomplish the following:

I have a folder that has a bunch of text files in it. I would like to
programatically open each file in a folder that contains the text '_MAST' in
it, copy the contents, and then paste it into an excel worksheet. I would
like it to keep looping through all of the text files in the folder until
all of the contents are pasted into one excel worksheet.

Any help would be greatly appreciated.

--
Regards,

timmulla

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default looping through txt files and pasting into a excel worksheet

Hey Ron,

The code works great for combining the text files. Is there any way to move
the files that don't contain the text '_MAST' out of the folder before I run
the Merge-CSV_Files macro. I'm only trying to combine the files that have
that text.

I'm thinking that moving the other files to another folder before running
the macro will solve the problem.

Any information would be greatly appreciated.

--
Regards,

timmulla


"Ron de Bruin" wrote:

Hi timmulla

Try the example on this page
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Can anyone help me create code to accomplish the following:

I have a folder that has a bunch of text files in it. I would like to
programatically open each file in a folder that contains the text '_MAST' in
it, copy the contents, and then paste it into an excel worksheet. I would
like it to keep looping through all of the text files in the folder until
all of the contents are pasted into one excel worksheet.

Any help would be greatly appreciated.

--
Regards,

timmulla


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default looping through txt files and pasting into a excel worksheet

Hi

Change this part

'Create the bat file
Open BatFileName For Output As #1
Print #1, "Copy " & Chr(34) & foldername & "*_MAST*.txt" _
& Chr(34) & " " & TXTFileName
Close #1


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Hey Ron,

The code works great for combining the text files. Is there any way to move
the files that don't contain the text '_MAST' out of the folder before I run
the Merge-CSV_Files macro. I'm only trying to combine the files that have
that text.

I'm thinking that moving the other files to another folder before running
the macro will solve the problem.

Any information would be greatly appreciated.

--
Regards,

timmulla


"Ron de Bruin" wrote:

Hi timmulla

Try the example on this page
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Can anyone help me create code to accomplish the following:

I have a folder that has a bunch of text files in it. I would like to
programatically open each file in a folder that contains the text '_MAST' in
it, copy the contents, and then paste it into an excel worksheet. I would
like it to keep looping through all of the text files in the folder until
all of the contents are pasted into one excel worksheet.

Any help would be greatly appreciated.

--
Regards,

timmulla


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default looping through txt files and pasting into a excel worksheet

Thanks, Ron. The code works great. I just realized that it's importing the
header rows from each of my txt files. Is there a way to only import the
header row from the first file? Or is it easier to loop through the excel
outoput file and delete the duplicate header rows?

Any information would be greatly appreciated.


--
Regards,

timmulla


"Ron de Bruin" wrote:

Hi

Change this part

'Create the bat file
Open BatFileName For Output As #1
Print #1, "Copy " & Chr(34) & foldername & "*_MAST*.txt" _
& Chr(34) & " " & TXTFileName
Close #1


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Hey Ron,

The code works great for combining the text files. Is there any way to move
the files that don't contain the text '_MAST' out of the folder before I run
the Merge-CSV_Files macro. I'm only trying to combine the files that have
that text.

I'm thinking that moving the other files to another folder before running
the macro will solve the problem.

Any information would be greatly appreciated.

--
Regards,

timmulla


"Ron de Bruin" wrote:

Hi timmulla

Try the example on this page
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Can anyone help me create code to accomplish the following:

I have a folder that has a bunch of text files in it. I would like to
programatically open each file in a folder that contains the text '_MAST' in
it, copy the contents, and then paste it into an excel worksheet. I would
like it to keep looping through all of the text files in the folder until
all of the contents are pasted into one excel worksheet.

Any help would be greatly appreciated.

--
Regards,

timmulla




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default looping through txt files and pasting into a excel worksheet

Change the start row

StartRow _
:=1

And copy the header row manual in the sheet one time when the code is ready


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Thanks, Ron. The code works great. I just realized that it's importing the
header rows from each of my txt files. Is there a way to only import the
header row from the first file? Or is it easier to loop through the excel
outoput file and delete the duplicate header rows?

Any information would be greatly appreciated.


--
Regards,

timmulla


"Ron de Bruin" wrote:

Hi

Change this part

'Create the bat file
Open BatFileName For Output As #1
Print #1, "Copy " & Chr(34) & foldername & "*_MAST*.txt" _
& Chr(34) & " " & TXTFileName
Close #1


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Hey Ron,

The code works great for combining the text files. Is there any way to move
the files that don't contain the text '_MAST' out of the folder before I run
the Merge-CSV_Files macro. I'm only trying to combine the files that have
that text.

I'm thinking that moving the other files to another folder before running
the macro will solve the problem.

Any information would be greatly appreciated.

--
Regards,

timmulla


"Ron de Bruin" wrote:

Hi timmulla

Try the example on this page
http://www.rondebruin.nl/csv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"timmulla" wrote in message ...
Can anyone help me create code to accomplish the following:

I have a folder that has a bunch of text files in it. I would like to
programatically open each file in a folder that contains the text '_MAST' in
it, copy the contents, and then paste it into an excel worksheet. I would
like it to keep looping through all of the text files in the folder until
all of the contents are pasted into one excel worksheet.

Any help would be greatly appreciated.

--
Regards,

timmulla


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
Looping through multiple sheets and pasting data in first blank ro Dan Excel Programming 1 September 18th 08 04:23 PM
Print Excel worksheet several times, looping value of 1 cell Hershmab Excel Programming 6 July 14th 07 07:48 PM
CAN I CLUB SIMILAR EXCEL FILES WITHOUT COPYING AND PASTING NAINAN JOSEPH Excel Discussion (Misc queries) 2 November 11th 06 06:56 AM
Looping through excel files to add to a new workbook Geoff Excel Programming 8 April 29th 06 11:54 AM
Looping thru files Tom Excel Programming 4 January 9th 04 05:05 PM


All times are GMT +1. The time now is 02:50 AM.

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

About Us

"It's about Microsoft Excel"