PDA

View Full Version : Copy fields from workbooks to a master workbook



violaplayer
06-30-2015, 02:04 AM
Hi

I am new to excel VBA, sorry if question has been raised by the others but I am hoping if someone could show me the exact syntax for my requirement below.

I have 200 excel files which have been saved in different path, but each of the file has the same fields and format (cloned from the same template). For example

=====================================
myTemplate.xls
Header (cell A1-A4): "Order_No" | "Product_Name" | "Quantity" | "Purchase_Date"

Files Paths
C:\Documents\Peter\London_Branch1_myTemplate_31032015.xls
C:\Documents\Peter\London_Branch2_myTemplate_31032015.xls
C:\Documents\Peter\London_Branch3_myTemplate_31032015.xls
C:\Documents\David\NewYork_Branch1_myTemplate_31032015.xls
C:\Documents\David\NewYork_Branch2_myTemplate_31032015.xls
C:\Documents\John\HongKong_Branch1_myTemplate_31032015.xls
C:\Documents\John\HongKong_Branch2_myTemplate_31032015.xls
C:\Documents\Susan\Paris_Branch1_myTemplate_31032015.xls
...............
...............
...............
...............
=====================================

I would like to write a VBA which can be able to the followings
1) Open the first file "London_Branch1_myTemplate_31032015.xls"
2) Copy all the entered rows
3) Paste into a single master single workbook says Global_Orders.xls

4) repeat step 1 to 3 for the second file until all 200 files. Basically it will stack up all the entries from each file into one big table.

Thank you very much

SamT
06-30-2015, 06:32 AM
How many sheets in the Template and which sheet has the data? Two questions.

ps: the solution I am considering requires that this (C:\Documents\) and this (myTemplate_31032015.xls) are real parts of the name.

Where do want to save Global_Orders.xls

violaplayer
06-30-2015, 07:57 AM
Hi SamT

Only one sheet in each template. Every individual would use the myTemplate.xls to record his/her records.
For Global_Orders.xls, it can be saved anywhere, say C:\Documents

Thank you very much