Hi,
I have a Excel Macro to unselect (or uncheck) some existing fields of a Pivottable but it's not working.
Any idea why?
Thanks in advance.
Sub RemoveDataFields()
For Each pf In ActiveSheet.PivotTables(1).PivotFields
If InStr(pf.Name, "trx") Then
pf.Orientation = xlHidden
End If
Next
End Sub
But it will work if I do this (I don't like it since it is lengthy):
Sub RemoveDataFieldsx()
ActiveSheet.PivotTables(1).PivotFields("abctrx1").Orientation = xlHidden
ActiveSheet.PivotTables(1).PivotFields("abctrx2").Orientation = xlHidden
...
...
ActiveSheet.PivotTables(1).PivotFields("abctrx19").Orientation = xlHidden
ActiveSheet.PivotTables(1).PivotFields("abctrx20").Orientation = xlHidden
End Sub
I have a Excel Macro to unselect (or uncheck) some existing fields of a Pivottable but it's not working.
Any idea why?
Thanks in advance.
Sub RemoveDataFields()
For Each pf In ActiveSheet.PivotTables(1).PivotFields
If InStr(pf.Name, "trx") Then
pf.Orientation = xlHidden
End If
Next
End Sub
But it will work if I do this (I don't like it since it is lengthy):
Sub RemoveDataFieldsx()
ActiveSheet.PivotTables(1).PivotFields("abctrx1").Orientation = xlHidden
ActiveSheet.PivotTables(1).PivotFields("abctrx2").Orientation = xlHidden
...
...
ActiveSheet.PivotTables(1).PivotFields("abctrx19").Orientation = xlHidden
ActiveSheet.PivotTables(1).PivotFields("abctrx20").Orientation = xlHidden
End Sub