Loop through PivotItems and Setting DrillDown to True

  • I am trying to loop through some Pivot Items in a PT and expand them based on their .Name property. My code currently looks like this:



    'expand entire fcast pivot table for Material and Supply and Outside Services Estimate Charge Types ONLY



    I keep getting a Run-time Error 1004: Unable to get the PivotFields property of the PivotTable class. I also want to expand the pivot items that are below these pivot items in the Pivot Table heirarchy.


    Thanks for any help!!!

  • Re: Loop through PivotItems and Setting DrillDown to True


    Make sure that the field name in your source data matches the specified pivot field name (ie. "Est. Chg. Type") in your code.


    Hope this helps!

  • Re: Loop through PivotItems and Setting DrillDown to True


    Dominic,


    The fields real name (estimate_charge_type_text) or the name that I gave the label in the PT? Both of them are returning the same error?


    Do you see anything else wrong with the code?


    Thanks,


    Jerid

  • Re: Loop through PivotItems and Setting DrillDown to True


    If the field name in the source data is "estimate_charge_type_text", then try replacing...


    Code
    1. Set pf = pt.PivotFields("Est. Chg. Type")


    with


    Code
    1. Set pf = pt.PivotFields("estimate_charge_type_text")


    Does this help?