Filter through macros in a pivot table in excel doesn´t work

25 Views Asked by At

I am making pivot tables with a Macro. Till now, my pivot table is created but when I try to filter the value which I assigned in filter, my pivot table doesn´t change and doesn´t add any filter. It keeps displaying me all the values for the field.

I have my pivot table as PTab. I made this code and I try making the filter through differet forms and any of them works.

Set PTab = PCache.CreatePivotTable(blatt.Range("A2"))

With PTab

    *'Filter*
    .PivotFields("GESCHÄFTSART").Orientation = xlPageField
*'1st attemot:   .PivotFilters.Add FilterType:=xlCaptionContains, Value1:="KONTO"*
*'2nd attempt*
    .PivotItems("KONTO").Visible = True
    .PivotItems("EVERGREEN").Visible = False

End With

My third attemot was with a With outside from the first one

With PTab.PivotFields("GESCHÄFTSART").strPattern("KONTO")
End With

And also I tried

With PTab.PivotFields("GESCHÄFTSART").PivotFilters.Add(FilterType := xlCaptionContains, Value1:="KONTO")
End With

And anything filters my Pivot Table

0

There are 0 best solutions below