Hi, I have the following code which transfers multiple "source" workbooks with a single sheet in each into a single "summary.xls" workbook over multiple sheets.
(1)What I'd like to do is copy a range (B10:O29) instead of the whole sheet...can anyone help? Everything I try gives me unwanted results.
(2)Additionally if its possible to copy each source sheet into the the summary.xls book one after another (i.e all on one sheet, rather than over multiple sheets) that would be ideal, but all I've tried has failed thus far.
Many thanks.
Sub Summarize()
Dim Counter As Long
Dim Source As Workbook
Dim Dest As Workbook
Const Directory As String = "Y:\DB\"
Application.ScreenUpdating = False
For Counter = 1 To 100
Set Source = Workbooks.Open(Directory & Counter & ".xls")
If Counter = 1 Then
Source.Worksheets("DB").Copy
Set Dest = ActiveWorkbook
Else
Source.Worksheets("DB").Copy After:=Dest.Worksheets(Dest.Worksheets.Count)
End If
Source.Close False
Next
Dest.SaveAs Directory & "Summary.xls"
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
(1)What I'd like to do is copy a range (B10:O29) instead of the whole sheet...can anyone help? Everything I try gives me unwanted results.
(2)Additionally if its possible to copy each source sheet into the the summary.xls book one after another (i.e all on one sheet, rather than over multiple sheets) that would be ideal, but all I've tried has failed thus far.
Many thanks.
Sub Summarize()
Dim Counter As Long
Dim Source As Workbook
Dim Dest As Workbook
Const Directory As String = "Y:\DB\"
Application.ScreenUpdating = False
For Counter = 1 To 100
Set Source = Workbooks.Open(Directory & Counter & ".xls")
If Counter = 1 Then
Source.Worksheets("DB").Copy
Set Dest = ActiveWorkbook
Else
Source.Worksheets("DB").Copy After:=Dest.Worksheets(Dest.Worksheets.Count)
End If
Source.Close False
Next
Dest.SaveAs Directory & "Summary.xls"
Application.ScreenUpdating = True
MsgBox "Done"
End Sub