Empty Pivot Field using a Macro

J

Jasper

although I tried a couple of options, I do not seem to sucseed in making a
macro which actualy empties the PivotField as I want to.

I tried:
ActiveSheet.PivotTables("PivotTable3").PivotFields("Count of Uren"). _
Orientation = xlHidden

But as the pivot Field is not always "Count of Uren", the macro Bug's as
soon as the PivotField is filled with something else.

Who knows how I can make this work? Thanks in Advance!
 
D

Debra Dalgleish

To clear all the pivot table's data fields:

'=========================
Sub RemoveDataFields()
Dim pt As PivotTable
Dim pf As PivotField
Set pt = ActiveSheet.PivotTables(1)

For Each pf In pt.DataFields
pf.Orientation = xlHidden
Next pf

End Sub
'==========================
 
Top