Hi All,
I am trying to write a macro that will copy sheets (in this case there is only one) from multiple workbooks in the same folder to the active workbook. I've tried the below code and am receiving errors. Any and all help is appreciated.
I am trying to write a macro that will copy sheets (in this case there is only one) from multiple workbooks in the same folder to the active workbook. I've tried the below code and am receiving errors. Any and all help is appreciated.
Code:
Option Explicit
Sub Combine_Exports()
Dim FolderPath As String
Dim Filename As String
Dim ws As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
FolderPath = "C:\Folder\Name\Project\Raw Data"
Filename = Dir(FolderPath & "*.xlsx*")
Do While Filename <> ""
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
For Each ws In ActiveWorkbook.Sheets
ws.Copy After:=ThisWorkbook.Sheets(1)
Next ws
Workbooks(Filename).Close
Filename = Dir()
Loop
Application.ScreenUpdating = True
Application.DisplayAlerts = False
End Sub