May 21, 2018

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)
ActiveWorkbook.Close Save = False

Application.DisplayAlerts = False

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

MyFile = Dir
Application.ScreenUpdating = True

End Sub

One thought on “Copy Sheet1 Data from Multiple Workbooks

  1. Dear Sir
    kindly can you make a excel VBA that can filter and copy from my cloud one drive excel to a master excel for some of the columns that i define.

Comments are closed.