Removing Field Subtotals except for 2 from from PivotTable

G

Gwen

Please assist

I have the following code to remove the field subtotals except for 2 from
pivot:

for Each pf In ActiveSheet.PivotTables("PivotTable2").PivotFields
If pf.Name = "field1" Or pf.Name = "field2" Then Exit For

pf.Subtotals = Array(False, False, False, False, False, False,
False, False, False, False, False, False)
Next

This code removes all subtotals; however, I want subtotals of the first 2
fields.

Thanks
Gwen
 
T

Tom Ogilvy

for Each pf In ActiveSheet.PivotTables("PivotTable2").PivotFields

If pf.Name <> "field1" and pf.Name <> "field2" Then r

pf.Subtotals = Array(False, False, False, False, False, False,
False, False, False, False, False, False)

End if

Next
 
G

Gwen

Thank you.

Tom Ogilvy said:
for Each pf In ActiveSheet.PivotTables("PivotTable2").PivotFields

If pf.Name <> "field1" and pf.Name <> "field2" Then r

pf.Subtotals = Array(False, False, False, False, False, False,
False, False, False, False, False, False)

End if

Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top