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

Published by

Dinesh Kumar Takyar

Welcome to! 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: For a structured Excel VBA training course online you can visit:

4 thoughts on “Create Summary Sheet from Multiple Workbooks with VBA”

  1. 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. 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. 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 *

This site uses Akismet to reduce spam. Learn how your comment data is processed.