3

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.

6
  • Did you try some code? Can you post it? Did you do research on the topic? What did you search for? What did you find? Commented May 5, 2017 at 6:44
  • No I couldnt find any reference. Foe adding Row, Column and Summation I had used as below. But nothing for FILTER. Commented May 5, 2017 at 7:18
  • Set pvtFld = PvtTbl.PivotFields("Order\ Amendment Approval Stage") pvtFld.Orientation = xlRowField pvtFld.Position = 5 Set pvtFld = PvtTbl.PivotFields("SOWPODateQtr") pvtFld.Orientation = xlColumnField pvtFld.Position = 1 Set pvtFld = PvtTbl.PivotFields("SERVICE ACV IN $ PLANNED") pvtFld.Orientation = xlDataField pvtFld.Position = 1 pvtFld.Function = xlSum pvtFld.NumberFormat = "#,##0" Commented May 5, 2017 at 7:18
  • What exactly do you need a reference for? How to apply filter to pivot table with VBA in Excel? Commented May 5, 2017 at 7:53
  • While creating a Pivot table manullay, we have the options to enter row fields, column fields, sum fields and then Filter fields. How do i replicate the 'Filter fields" options using VBA ? Commented May 5, 2017 at 8:22

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Is it not easy as adding a row/Column syntax to a pivot. Somehting like this >
Set pvtFld = PvtTbl.PivotFields("Account") pvtFld.Orientation = xlRowField pvtFld.Position = 1
0

Try below line of codes

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.