Latest Posts

Copy Sheet1 Data from Multiple Workbooks

How to copy sheet1 data from multiple workbooks into multiple worksheets in a new workbook automatically with VBA. A user wants to create a report by transferring data of Sheet1 from multiple workbooks with multiple sheets into separate worksheets in a new workbook. Watch the video:

Watch this video on YouTube.

Here’s the complete VBA code to copy-paste data from a specific sheet from multiple workbooks with multiple worksheets automatically into a new workbook with multiple worksheets:

Sub LoopThroughDirectory()
Dim MyFile As String
Dim q As Long
q = 1
Dim Filepath As String
Filepath = “C:\copy-51\”
Application.ScreenUpdating = False
MyFile = Dir(Filepath)
Do While Len(MyFile) > 0

Workbooks.Open (Filepath & MyFile)
Worksheets(“Sheet1”).Activate
ActiveSheet.UsedRange.Copy
ActiveWorkbook.Close Save = False

Application.DisplayAlerts = False

Sheets(q).Select
ActiveSheet.Paste Destination:=Worksheets(q).Range(“A1”)
Application.CutCopyMode = False
q = q + 1
If q > 4 Then
Exit Sub
End If

MyFile = Dir
Loop
ActiveWorkbook.Save
Application.ScreenUpdating = True

End Sub