Hi There
Building on from this here – how do I remove the PivotField("#") from the Values field
The below macro basically goes through the 2 pivot charts and puts the pivot field “#” in the Values field in position 1
Now how do I reverse this and remove it
Sub Macro8_how_to_target_Line_test_T_J()
'
' Macro8 Macro
'
'
Dim ws As Worksheet
Dim objPT As PivotTable
Dim objPTField As PivotField
For Each ws In Worksheets
ws.Visible = xlSheetVisible
For Each objPT In ws.PivotTables
MsgBox "Pivot table name: " & objPT.Name & vbCrLf & "Sheet name: " & ws.Name & vbCrLf & "test"
' With objPT.PivotFields("#3") ', "Sum of #3", xlSum
With objPT.PivotFields("#")
.Orientation = xlDataField
.Function = xlSum
.Position = 1
End With
Next objPT
Next ws
End Sub
I have tried adding something like the below to remove it but I cannot work it out. Appreciate any help.
Sub Macro11()
'
' Macro11 Macro
'
'
ActiveSheet.PivotTables("PivotTable1").PivotFields("Sum of #").Orientation = _
xlHidden
End Sub
Bookmarks