Using VBA to Filter a Pivot Table - How to add Two Filters

  • I have some sample code below that is working fine for me. Currently has one filter (on Facility Number) and I want to add another filter.



    I am having a problem with this line.


    .PivotFields("Facility Number").PivotFilters.Add Type:=xlCaptionEquals, Value1:=myfilterFacNum


    Which filters the pt as desired. But how do I add a "second filter" - seems I cannot get the syntax correct. thanks for your suggestions.

  • I thought about an example but since the code is working correctly for me I decided to just show the code.


    Since ".PivotFields("Facility Number").PivotFilters.Add Type:=xlCaptionEquals, Value1:=myfilterFacNum" is the line of interest; and more specifically, "Value1:=myfilterFacNum" is the filter being applied to the pivot table.


    I am asking how do I insert a "Value2:=myfilter2" using the "PivotFilters" property so the pivot table will now be filtered on Two Criteria.


    Thanks for your response.