Hi guys, I use the following code to try to copy multiple worksheets in one file:
The code opens all four workbooks and now is my question how to copy these workbooks to one (master)workbook. Thank you in advance!
Code:
Option Explicit
Sub CombineData()
Dim oWbk As Workbook
Dim sFil As String
Dim sPath As String
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
.AskToUpdateLinks = False
' On Error GoTo exithandler
sPath = "C:\Users\kber\Desktop\Kevin\Projecten\Integratie advieslijsten"
ChDir sPath
sFil = Dir("*.xls")
Do While sFil <> "" 'will start LOOP until all files in folder sPath have been looped through
Set oWbk = Workbooks.Open(sPath & Application.PathSeparator & sFil) 'opens the file
oWbk.Sheets.Copy
oWbk.Close False 'close source workbook
sFil = Dir
Loop ' End of LOOP
exithandler:
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub