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:
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:
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.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
PivotTables are often used to aggregate lots of information, and they do it beautifully. What do you do if Excel starts ...
Discover MoreWhen you create a PivotTable, Excel automatically sums the data that you place into the Data Items area of the table. ...
Discover MoreExcel allows you to link to values in other workbooks, even if those values are in PivotTables. However, Excel may ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-01-23 10:15:38
Petrpan
Your solution just uncheck option "Save source data with file" on page Data in "PivotTable Options" dialog. So you can do it w/o macro.
But if Iprepare PivotTable connected to our server database and then I send it to customer, he will not be able to change pivot look. Even if I want to do it, it requests to refresh Pivottable first. But client outside of company can't refresh it, since he has not access to database on our server.
Strange is, if I create the same pivot (data and look) from beginning, it's much smaller than that one I refreshed few times. And that I complain about, there should be some option to delete old data (of course I set "Number of items to retain per field" to None).
2019-01-10 07:46:46
Eduardo
Great help thx a lot!
2018-03-07 06:48:41
Harish
Really worked a lot for me... Struggling a lot on working Big files.
thanks a log
2017-05-04 10:38:11
zenande yaphi
to those tips i've read above i don't get the information that i was asked for
2016-10-04 04:34:37
Sarunas
Please keep in mind that if you have any custom fields setup they will disappear even if you have one data source. This macro is useful only if you have designed pivot table with no custom calculable fields.
2016-03-31 09:58:12
jonathan
another easy way to cut down on bloat from multiple pivots on the same source, is to create the first one and then actually copy the pivot onscreen, and past somewhere else .. then modify to what you want as your second pivot. I believe this dictates to Excel that the original data source be used. Another great trick is to build and refresh your pivot table, then delete the actual data that originally fed it. The pivot cache retains all of the data and you can send to your user who can pivot to their heart's content. If they want to see the raw data, they need only click on the grand total of the pivot and it will all be displayed on a new tab. This cuts WAY down on filesize since you are essentially getting rid of duplicate data, but it depends on your process and user expectations.
2015-05-20 17:44:04
Coral
I have the same question as Joe!
2015-03-06 17:16:59
Joe
This works really well for my workbook that points to one data set. However, I have another sheet that has two very large datasets, what manipulations should be made to the code to fix this? because it will attempt to overwrite all pivot tables with one of the two datasets.
Thanks for any additional support you can give.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2022 Sharon Parq Associates, Inc.
Comments