Hi All,
I am trying to loop through all pivot tables in a sheet and remove all values fields in them which have the same name: "Total Net Spend" and "% Split".
I am trying the below code but it will only work on the first pivot and won't loop through all of them. How do I edit the code so that it will remove "Total Net Spend" and "% Split" columns on all the pivot tables in the sheet?
Sub Loop_Pivots()
Dim PT As PivotTable, PTField As PivotField
Set PT = Sheets("Sheet1").PivotTables("Pivot1")
With PT
.ManualUpdate = True
For Each PTField In .DataFields
PTField.Orientation = xlHidden
Next PTField
.ManualUpdate = False
End With
Set PT = Nothing
End Sub
Thanks,
Andrea
I am trying to loop through all pivot tables in a sheet and remove all values fields in them which have the same name: "Total Net Spend" and "% Split".

I am trying the below code but it will only work on the first pivot and won't loop through all of them. How do I edit the code so that it will remove "Total Net Spend" and "% Split" columns on all the pivot tables in the sheet?
Sub Loop_Pivots()
Dim PT As PivotTable, PTField As PivotField
Set PT = Sheets("Sheet1").PivotTables("Pivot1")
With PT
.ManualUpdate = True
For Each PTField In .DataFields
PTField.Orientation = xlHidden
Next PTField
.ManualUpdate = False
End With
Set PT = Nothing
End Sub
Thanks,
Andrea