Prashant Jain
Prashant Jain

Reputation: 21

Pivot Table Report Filter using VBA

I am trying to automate a particular Pivot table filtering using VBA. I am not sure how to add "Report Filter" (please see attached screen shot) using VBA.

To automate the process, I got the code for adding rows , columns and values , but can't seem to find the code for report filter.

Can you please help me out with the code for this.

Filter

Report Filter

Upvotes: 1

Views: 1734

Answers (1)

Prashant Jain
Prashant Jain

Reputation: 21

Thanks @avb for the suggestion . Recording the macro helped. The code for adding pivot report filter is this.

    Sub pivotReportFilter(ptUse As PivotTable, fName As String)

     With ptUse.PivotFields(fName)
      .Orientation = xlPageField
      .Position = 1
     End With

   End Sub

Upvotes: 1

Related Questions