Removing Subtotals from Many PivotTable Fields

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


2

Shairal develops PivotTables on a daily basis, using various data sources such as Excel lists, Access tables, and OLAP data. One of the most irritating things he deals with is suppressing the automatic subtotal function on each field, one at a time. This can be time consuming depending on the number of fields he's used. Shairal wondered if it might be easier to use a macro to suppress the subtotals for all the fields at once.

The answer is that it would be easier to use a macro. (That is what macros are for—to take care of the tedious things you tire of.) Rather than reinvent the wheel, however, a good solution is to consider the following code, adapted from Microsoft MVP Debra Daglisesh's site:

Sub NoSubtotals()
    'turns off subtotals in pivot table
    '.PivotFields could be changed to
    '.RowFields or .ColumnFields

    Dim pt As PivotTable
    Dim pf As PivotField

    On Error Resume Next
    For Each pt In ActiveSheet.PivotTables
        For Each pf In pt.PivotFields
            'First, set index 1 (Automatic) to True,
            'so all other values are set to False
            pf.Subtotals(1) = True
            pf.Subtotals(1) = False
        Next pf
    Next pt
End Sub

Just display the PivotTable you want to affect, and then run the macro. The subtotals for all the fields in the PivotTable are suppressed at once. The original for this code is available here, at Debra's site:

http://www.contextures.com/xlPivot03.html#Subtotals

The site also contains some other good information for working with PivotTables.

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 (3103) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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 All Names but a Few

Want to get rid of most of the names defined in your workbook? You can either delete them one by one or use the handy ...

Discover More

Hiding and Displaying Hidden Text

You can easily hide text by simply changing the attributes associated with the text. Once that is done, you can turn the ...

Discover More

Removing Line Numbering

If you've added line numbers to your document, at some point you may want them turned off. Here's how to disable line ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Default Formatting for PivotTables

Wish there was a way to define how you want PivotTables formatted before you actually create the PivotTable? You may be ...

Discover More

Maintaining Formatting when Refreshing PivotTables

When you refresh the data in a PivotTable, Excel can play havoc with whatever formatting you applied. Here's how to ...

Discover More

Text Truncated in PivotTable

When you create a PivotTable based on data that contains lots of text, you may be surprised to find that your text is ...

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 two more than 7?

2020-07-04 06:09:24

O.Ezeakile

Thanks a lot.


2019-11-26 14:17:34

Denis

Nice cod bro. Thanks a lot.


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.