bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > PivotTables > Removing Subtotals from Many PivotTable Fields

Removing Subtotals from Many PivotTable Fields

Summary: Put together a large PivotTable, and you can have many different fields to format or otherwise configure. If you want to get rid of all the subtotals on your PivotTable fields, the work can become quite tedious. That is where the macro highlighted in this tip comes in handy—it can remove all your subtotals in one easy step. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, and Excel 2003.)

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 I've 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 yes, 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 PivotTable
    '.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.

Tip #3103 applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003


Got the Time? Understanding the ins and outs of working with times and dates can be confusing. Remove the confusion--ExcelTips: Times and Dates is an invaluable resource for learning how best to work with times and dates.
 
Check out ExcelTips: Times and Dates today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Bugs and Pests Tips
ExcelTips
Family Tips
Health Tips
Home Tips
Organizing Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)