Share via

Pivot Table Filter Error

Anonymous
2019-03-13T10:08:10+00:00

I use Record Macro to filter PivotTable "PR to PO Days" field label filter between 0 and 4. When i record, it can filter correctly, only show 1, 2 & 4. But when i run the macro, it is not filter correctly, 24 which is should not show always show.

Hope can get help. Thank you!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2019-03-14T02:03:36+00:00

    I know the answer. Remove " " from the number 0 & 4. Else it is treated as text not number.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2019-03-14T01:29:51+00:00

    Thank you for your help. Because i want to modify the coding the values filter in between are variable (numbers key in by users at cells). So i cannot know what's the values are to filter.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2019-03-13T18:07:51+00:00

    Hi,

    try this....

    Sub Macro20_new ()

    ' ### 13 Mar 2019 ###

    Dim pi As PivotItem

    ActiveSheet.PivotTables("PivotTableMacro4").PivotFields("PR to PO Days").ClearAllFilters

    For Each pi In ActiveSheet.PivotTables("PivotTableMacro4").PivotFields("PR to PO Days").PivotItems

    Select Case pi

    Case "0", "1", "2", "3", "4"

    Case Else

    pi.Visible = False

    End Select

    Next pi

    End Sub

    Was this answer helpful?

    0 comments No comments