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

Changing Text Orientation

Word allows you to change the orientation of text contained within certain objects, such as AutoShapes, text boxes, and ...

Discover More

Setting Up Your Printer

Need your printed output to look its best? You may need to change the settings used by your printer, then. Here's how to ...

Discover More

Keep with Previous

Word allows you to format a paragraph so that it is on the same page as whatever paragraph follows it. You may want, ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (menu)

Shortcut to Move between Two Worksheets

Moving between to adjacent worksheets is easy; Excel provides a shortcut key to do the trick. If you want to move between ...

Discover More

Ordering Worksheets Based on a Cell Value

Need to sort your worksheets so that they appear in an order determined by the value of a cell on each worksheet? Using a ...

Discover More

Quickly Inserting a New Worksheet

Want a quick way to insert a worksheet? There's nothing faster than using the handy shortcut.

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 2 + 2?

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.