0

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. Because later i want to modify the coding the values to filter in between are variable (number key in by users at cells).

Hope anyone can get help. Thank you!enter image description here

1 Answer 1

2

Remove the quotation marks from "0" and "4", otherwise the filter considers the values as text and not as values. In a text comparison, "24" falls between "0" and "4".

With ActiveSheet.PivotTables("PivotTableMacro4").PivotFields("PR to PO Days")
    .ClearAllFilters
    .PivotFilters.Add Type:=xlCaptionIsBetween, Value1:=0, Value2:=4
End With
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.