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: Reducing File Sizes for Workbooks with PivotTables.

Reducing File Sizes for Workbooks with PivotTables

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


PivotTables are great for certain types of data analysis. Since PivotTables do quite a bit of number crunching, one of the techniques Excel uses to process them faster is to create an "intermediate dataset" to work with. This intermediate dataset, by default, is stored with the worksheet, so PivotTables can increase the size of your workbooks, sometimes dramatically.

If your workbook contains multiple PivotTables, all based on a single data source, Excel may create an intermediate dataset for each PivotTable, instead of using one intermediate dataset. This, of course, could increase the size of your workbook very rapidly.

You can control how Excel creates the intermediate dataset by modifying the options you choose in the PivotTable Wizard that puts your PivotTable together. If you have one PivotTable in your workbook, and when running the PivotTable Wizard a second time you specify the same data source that you used in the existing PivotTable, Excel informs you that "Your new report will use less memory if you base it on your existing report." If you click Yes, you will save memory because Excel will use the same intermediate data as it used for your other PivotTable.

You can also instruct Excel to not save your intermediate data tables in the same disk file with the workbook. This will make the size of your workbook file much, much smaller, but it will also require that PivotTables be refreshed every time you open your workbook. Follow these steps:

  1. Run the PivotTable Wizard to create your PivotTable as you normally would.
  2. When you get to the final screen of the PivotTable Wizard (the one with the checkered flag on it), click the Options button to display the PivotTable Options dialog box.
  3. Clear the Save Data with Table Layout check box.
  4. Choose the Refresh on Open check box.
  5. Click on OK to close the PivotTable Options dialog box.
  6. Finish the steps in the PivotTable Wizard.

You don't need to choose the Refresh on Open check box (step 4) if you don't want to, but if you don't, you will need to remember to manually refresh the PivotTable every time you open the workbook.

If you already have quite a few PivotTables in your workbook, and you don't want to go through the process of creating them again, you can use a macro to step through the PivotTables and modify the caching index and turn off the saving of the intermediate data to disk. The following macro will accomplish these tasks:

Sub PTReduceSize()
    Dim wks As Worksheet
    Dim PT As PivotTable

    For Each wks In ActiveWorkbook.Worksheets
        For Each PT In wks.PivotTables
            PT.RefreshTable
            PT.CacheIndex = 1
            PT.SaveData = False
        Next
    Next
End Sub

Once the macro runs (it won't take long), you should save your workbook using the Save As option. This will write a new workbook file, and you will be able to compare how much this change reduced the size of your workbook. Remember, however, that with the intermediate data not being saved to disk, the refreshing of the PivotTables takes longer when you first open the workbook.

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 (2851) 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: Reducing File Sizes for Workbooks with PivotTables.

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

Deleting Tab Stops

Need to delete some tabs tops in a paragraph? It's easy to do using the Tabs dialog box, as described in this tip.

Discover More

Transposing Table Contents

When you transpose information, it is essentially "rotated" in a direction. If you transpose the information in a table, ...

Discover More

Renaming a Workbook

Renaming a workbook from within Excel can seem daunting, but it is actually quite easy. All you need to do is use the ...

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)

Too Many Rows or Columns in a PivotTable

PivotTables are often used to aggregate lots of information, and they do it beautifully. What do you do if Excel starts ...

Discover More

Editing PivotTables without Underlying Data

If you ever try to edit a PivotTable and get an error that tells you that the "underlying data was not included," it can ...

Discover More

Error in Linked PivotTable Value

Excel allows you to link to values in other workbooks, even if those values are in PivotTables. However, Excel may ...

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 nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


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.