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

Published by

Dinesh Kumar Takyar

Welcome to exceltrainingvideos.com! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: http://youtube.com/familycomputerclub For a structured Excel VBA training course online you can visit: https://www.youtube.com/excelvbaonline

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.

Leave a Reply

Your email address will not be published. Required fields are marked *