Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pf In .PivotFields gets rid of all the information in a Pivot Table

Status
Not open for further replies.

makeitwork09

Technical User
Sep 28, 2009
170
US
I am using Excel 2007 on Windows 7.

The code below gets rid of everything, the row fields and the data fields, thus only leaving the header rows, eventually resulting in an error that reads "Unable to set the subtotal property of the pivot class".
Code:
       For Each pf In .PivotFields
            pf.Subtotals(1) = True
            pf.Subtotals(1) = False
        Next pf

Any ideas on how I can fix this?

Thanks

Pam
 
I change the above code to the following. When I did that the code ran without an error, but it still got rid of everything, leaving only the header.I replaced .PivotFields with .RowFields

Code:
        For Each pf In .RowFields             
            pf.Subtotals(1) = True
            pf.Subtotals(1) = False
        Next pf
 
I solve the problem. I had the following code after the code above. That is what was causing the information to "disappear".

Code:
        'calculate the pivot table
        PT.ManualUpdate = False
        PT.ManualUpdate = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top