Home » excel » excel – VBA Pivot Table: Add Filter

excel – VBA Pivot Table: Add Filter

Posted by: admin April 23, 2020 Leave a comment


Using VBA code, I have created a Pivot table and then added row, columns and then the summation values. Now I need to add a filter on a column.
Can you please let me know how can I add filters to this column.

How to&Answers:

Try the following code:

Sub Makró2()
    With ActiveSheet.PivotTables("Kimutatás1").PivotFields("a")
        .PivotItems("asd").Visible = False
        .PivotItems("hj").Visible = False
    End With
End Sub

For example:

enter image description here


Try below line of codes

With ActiveSheet.PivotTables("PivotTable Name").PivotFields("Column Name").Orientation = xlPageField.Position = 1