Create Summary Sheet from Multiple Workbooks with VBA

How to create a summary sheet from multiple workbooks with VBA automatically. An Excel user might have data in hundreds of workbooks in a folder and he would like to create a summary of all the data in his workbooks quickly and automatically. Such data can be invoices, collection of DVDs or books, students’ data, etc. Let’s see how we can summarize such data quickly and easily with VBA by watching the video below:

Watch this video on YouTube.

Here’s the complete VBA code:

Sub createSummarySheet()
Dim SummarySht As Worksheet
Dim FolderPath As String
Dim BlankRow As Long
Dim FileName As String
Dim WorkBk As Workbook
Dim SourceRange As Range
Dim DestRange As Range
Dim lastrow As Long
Set SummarySht = ActiveWorkbook.Worksheets(1)
FolderPath = “C:\TestMF\”
BlankRow = 2
FileName = Dir(FolderPath & “*.xl*”)

Do While FileName <> “”
Set WorkBk = Workbooks.Open(FolderPath & FileName)
SummarySht.Range(“A” & BlankRow).Value = FileName
lastrow = WorkBk.Sheets(“sheet1”).Range(“A” & Rows.Count).End(xlUp).Row
Set SourceRange = WorkBk.Worksheets(1).Range(Cells(2, 1), Cells(lastrow, 2))
Set DestRange = SummarySht.Range(“B” & BlankRow)
Set DestRange = DestRange.Resize(SourceRange.Rows.Count, SourceRange.Columns.Count)
DestRange.Value = SourceRange.Value
BlankRow = BlankRow + DestRange.Rows.Count
WorkBk.Close savechanges:=False
FileName = Dir()

End Sub

Further Reading:

Merging Data from Multiple Workbooks into a Summary Workbook in Excel 2010

3 thoughts on “Create Summary Sheet from Multiple Workbooks with VBA

  1. Jay

    Hi Dinesh,

    I am having trouble running the script you provided and was hoping you could help. Each time I attempt to run the macro, i receive an error stating “vba compile error invalid or unqualified reference”. At that point, the debug highlights the “FileName = Dir(FolderPath & “*.xl*”)” line. Any ideas why this might be?

  2. Bobbie

    It really is gorgeous, much more than all high priced totes. I feel modern and classy i got the budget to go with it. Finding a lot of words of flattery into it! The good thing isn2&8#17;t animals acquired harm that i can look wonderful!

  3. Akpofure

    Hello Sir,
    I have a similar data set but the date actually comes as daily report but what i want to do is to pick up some data from each workbooks for each day, i.e the report is to be consolidated for each month (30/31 day ) of the month. how do i go around it. data should be consolidated automatically.


Leave a Reply

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