none
VBA code to paste data from a Pivot Table built from a Data Model RRS feed

  • Question

  • Hi,

    I have a Pivot Table built from a Data Model.  This Pivot Table has a Year and a Month Name field in the row labels and a host of others as well.  My requirement is to filter each month within each year and append the data in a new Excel file (which should be saved on the desktop).  The following VBA code works very well when I build the Pivot Table from a standard Excel range.  However, it does not work when I build the Pivot Table from the Data Model.  When I step through the VBA code, the line which throw up an error is

    Set PFy = PT.PivotFields("Year")

    Run-Time error is '1004': Application-defined or object-defined error

    Could you kinldy help me resolve the issue.

    I have also posted this question in the MS Excel forums here.

    Thank you very much.


    Regards, Ashish Mathur Microsoft Excel MVP www.ashishmathur.com

    Thursday, February 6, 2020 3:03 AM