PDA

View Full Version : Solved: Add opened file into a summary workbook



hi77l
08-17-2009, 12:45 AM
Hi!

I am new to using VB in excel and I need some help. I am doing a program where in I need to open several files in a folder then add those opened sheets in a file, this file contains 1 sheet which will summarize all the data in the opened worksheets. I have a sample code but this code will create new file not add the opened files into a summary file.
sample code:

Dim newWB As Workbook, aWB As Workbook
Set newWB = Workbooks.Add
For Each aWB In Application.Workbooks
If aWB Is newWB Or aWB Is ThisWorkbook Then
Else
aWB.Sheet(1).Move after:=newWB.Sheet(1)
End If
Next aWB

Hope you could help me. Thanks

hi77l: pray2:

Bob Phillips
08-17-2009, 01:23 AM
You can easily get a master wb like so



Dim masterWB As Workbook, aWB As Workbook
Set masterWB = Workbooks("Master.xls")
For Each aWB In Application.Workbooks


But ... this code is iterating through already opened workbooks. Do you want to open other workbooks in a nominated directory and process those?

Simon Lloyd
08-17-2009, 01:29 AM
hi77l, you posted this question at MrExcel here http://www.mrexcel.com/forum/showthread.php?t=410098 at 03:40 ish this morning, 5 hours is not a sufficient waiting time before crossposting!, if you must cross post please supply the link(s) to every other thread you created in every other forum - read the link about crossposting in my signature to see why it can be a problem :)