LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default How do I pull data from multiple files and copy into one file

I used the macro copy function and created the following:

Workbooks.Open ("C:\2001.xls")
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Copy
Windows("Macro_try2").Activate
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(columnOffset:=-1).Activate
ActiveCell.FormulaR1C1 = "'2001"
ActiveCell.Offset(columnOffset:=1).Activate
Range(Selection, Selection.End(xlDown)).Select
Windows("2001.XLS").Activate
ActiveWorkbook.Close
Windows("Macro_try2.XLS").Activate
Selection.End(xlDown).Select
ActiveCell.Offset(rowOffset:=1).Activate

This works great for one file, but I have a directory with over 200 files
that need the same action.

How do I select the next file in the directory after finishing with one?

As you can see the file name is used in 3 different lines in the macro. How
do I go from one file to the next and update the macro with the current file
name?

I would like to be able to copy the file name down the column it is in for
all rows out of that file, but even the relative copy function pastes data
into a specific range. What code would I use to set the paste range equal to
the number of rows copied?

Any guidance is appreciated.


 
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
Macro to pull data from another file - update name of file Don Excel Discussion (Misc queries) 2 February 10th 09 03:31 PM
Pull data from a file Marina Excel Discussion (Misc queries) 3 July 2nd 07 04:12 PM
pull data for a company with data in diff cells multiple wrkshts kcoachbiggs Excel Worksheet Functions 0 March 8th 06 09:24 PM
Pull multiple data luk_sr Excel Worksheet Functions 6 August 2nd 05 09:20 PM
How to pull data out of an excell file with multiple tabs mdeanda Excel Worksheet Functions 1 May 28th 05 02:21 AM


All times are GMT +1. The time now is 11:41 AM.

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"