Filter Pivot Table with Marco

  • creating what I thought would be a simple script however do not seem to be able to filter the results in the pivot table as I would like. As you can see below there are multiple criteria selected however they are not a complete sequence 1-whatever as the data does not necessarily contain every digit (number of days) - the result of recording the macro was only limiting results of days in the actual data and since not every day appears in the data this macro and script will not work consistently. So I am looking for a way to resolve this and wondering if I can create an if then statement in the script that would eliminate all values greater than 45?

    With ActiveSheet.PivotTables("PivotTable1").PivotFields("APP TO CTC")

    .PivotItems("46").Visible = False

    .PivotItems("47").Visible = False

    .PivotItems("48").Visible = False

    .PivotItems("50").Visible = False

    .PivotItems("51").Visible = False

    .PivotItems("54").Visible = False

    .PivotItems("55").Visible = False

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!