I have a number of datafields i'm inserting into a pivot table. That number of fields can be different each time the code is executed. Is there a way to assign an Array to add data fields? I tried this:
ActiveSheet.PivotTables("Heads").AddDataField ActiveSheet.PivotTables("Heads").PivotFields(Range("Dates")), Array(Range("Dates")), xlSum
and get a pivot table class error. I'm a beginner .
ActiveSheet.PivotTables("Heads").AddDataField ActiveSheet.PivotTables("Heads").PivotFields(Range("Dates")), Array(Range("Dates")), xlSum
and get a pivot table class error. I'm a beginner .