Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Condensing Multiple Worksheets Into One.

Condensing Multiple Worksheets Into One

Written by Allen Wyatt (last updated February 9, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003


4

If you get workbooks that have identically structured data on each worksheet, you may be interested in a way to combine the multiple worksheets into a single, large worksheet.

The concept behind doing the condensation is rather easy: You simply need to copy the data from the second and subsequent worksheets to the first empty row on the first worksheet. Fortunately, Excel includes a feature that allows you to do this very process—the Consolidate tool.

The Consolidate tool allows you to combine worksheets where data is defined by position or by category. By position means that the data is in the same position on every worksheet. For instance, if the data tables on each worksheet have the exact same columns, then you would consolidate by position. By category means that you want to combine data from tables in which the data may not use a consistent structure. You use this type of consolidation if the columns in the data tables are in different orders.

In the workbook whose worksheets you want to consolidate, choose Data | Consolidate. Excel displays the Consolidate dialog box. (See Figure 1.) There are many controls in the dialog box, but the primary thing you need to worry about is specifying the ranges to consolidate.

Figure 1. The Consolidate dialog box.

You specify ranges by using the Reference box. Specify in the box the first range you want to consolidate. If you are consolidating by position, then the reference should not contain any column labels; if by category, then you should. When you specify the range reference, you click Add, and the reference appears in the All References list. You continue to define reference ranges until they are all complete.

If you want the consolidated data to contain links to the original data, then make sure the Create Links to Source Data check box is selected, otherwise clear it. You can then click OK to do the consolidation.

Note that there are other controls in the Consolidate dialog box; the controls mentioned above are the ones you should pay attention to at a minimum. The best way to find out what the others do is to play around with them, doing a few consolidations.

If you prefer to not use the Consolidate tool, you can easily create a macro that will do the consolidation for you—provided the structure of each worksheet is identical. The following macro steps through all the worksheets and combines the data to a new worksheet it adds at the beginning of the workbook.

Sub Combine()
    Dim J As Integer

    On Error Resume Next
    Sheets(1).Select
    Worksheets.Add ' add a sheet in first place
    Sheets(1).Name = "Combined"

    ' copy headings
    Sheets(2).Activate
    Range("A1").EntireRow.Select
    Selection.Copy Destination:=Sheets(1).Range("A1")

    ' work through sheets
    For J = 2 To Sheets.Count ' from sheet 2 to last sheet
        Sheets(J).Activate ' make the sheet active
        Range("A1").Select
        Selection.CurrentRegion.Select ' select all cells in this sheets

        ' select all lines except title
        Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select

        ' copy cells selected in the new sheet on last line
        Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
    Next
End Sub

When the macro is done, the first sheet in the workbook, named Combined, has all the data from the other worksheets. The other worksheets remain unchanged.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3005) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Condensing Multiple Worksheets Into One.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Performing Calculations while Filtering

The advanced filtering capabilities of Excel allow you to easily perform comparisons and calculations while doing the ...

Discover More

Changing the Start Screen's Theme

You'll spend a lot of time viewing the Start screen in Windows. If you want to change up things, you can modify which ...

Discover More

Inserting a Non-Breaking Space

In Word a non-breaking space will help you keep two words together on the same line. Here's two different ways that you ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Creating a Copy without Formulas

Excel makes copying worksheets (duplicating them) rather easy. However, you may want a worksheet copy that differs from ...

Discover More

Synchronized Workbook and Worksheet Names

When you work on older workbooks in Excel, you may notice that the name of the worksheet tab and the workbook itself are ...

Discover More

Combining Worksheets from Many Workbooks

Do you need to pull a particular worksheet out of a group of workbooks and combine those worksheets into a different ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven minus 7?

2020-09-16 03:21:18

Alan Elston

Tom H
Probably VBA is the best way to do it. But in VBA there are very many different ways to do it , and the best or easiest way will depend on what your data looks like, what , if any formatting is required etc… etc…
You would probably be best to make a greatly reduced size sample workbook, with just a few worksheets, and ask the question at one of the Excel help forums, such as excelforum or excelfox or mrexcel or ozgrid
Better would be two workbooks. One should be the Before. The other, the After, would be hand filled in by you to show exactly what you want to do.
Alan Elston


2020-09-15 10:17:54

Tom H

I was looking for a way to take a file with 100 sheets with 3 to 40 rows of data on each sheet and automatically essentially cut and paste each sheets data into a master sheet. So if each sheet had 40 rows and there were 100 sheets, the master sheet would have 4000 rows. What's the easiest way to do that? Thanks, Tom


2020-04-17 15:10:27

Bob

This works very well. My spreadsheets had some sheets with headings only (there were no actual data rows), and the macro copied over the headings for those sheets. I made a quick change to take care of that. There are probably more elegant ways to handle it but this worked:

Sub Combine()
Dim J As Integer

On Error Resume Next
Sheets(1).Select
Worksheets.Add ' add a sheet in first place
Sheets(1).Name = "Combined"

' copy headings
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")

' work through sheets
For J = 2 To Sheets.Count ' from sheet 2 to last sheet
Sheets(J).Activate ' make the sheet active
Range("A1").Select
Selection.CurrentRegion.Select ' select all cells in this sheets

' only copy non-empty sheets
If Selection.Rows.Count > 1 Then

' select all lines except title
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select

' copy cells selected in the new sheet on last line
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
End If
Next
End Sub


2019-03-15 07:38:26

Stu

Hello,

Thanks for this script. However I've tried this with a Excel file with 90 sheets and it doesn't select all of the sheets (some of them don't get selected) - approx 85 out of the 90. Any ideas as to why this may be.

Regards
Stu


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.