Macro to combine different workbooks


Combine workbooks in the specified folder


Sub CombineWorkBooks()
Dim folderpath As String
Dim filename As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
folderpath = "F:\Monthly Sales Data\"
filename = Dir(folderpath & ".xls")
Do While filename <> ""
Workbooks.Open filename:=folderpath & filename, ReadOnly:=True
For Each Sheet In ActiveWorkbook.Sheets
Sheet.Copy After:=ThisWorkbook.Sheets(1)
Next Sheet
Workbooks(filename).Close
filename = Dir()
Loop
Application.ScreenUpdating = True
End Sub

Note: “F:\Monthly Sales Data\” is the path of the folder containing the workbooks and can be replaced by the folder path of your choice.


How to use codes shared here?