• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to filter Pivot table with Dates

vasim

Member
Sub run()


Sheets("Pivot 2").PivotTables("Pivottable1").PivotFields("Date").ClearAllFilters

For i = 1 To 5

Sheets("Pivot 2").PivotTables("Pivottable1").PivotFields("Date").PivotItems(i).Visible = False

Next i


End sub


The above code is working great with strings/text but isnt working on date, any assistance please.
 
Hi ,


Can you try this ?

[pre]
Code:
Sheets("Pivot 2").PivotTables("Pivottable1").PivotFields("Date").PivotItems.Item(i).Visible = False
[/pre]
Narayan
 
Thanks for help Narayank...but it still throws an error as "Run Time error 1004. Unable to set the visible property of the pivotitem class"...


Any help
 
Hi ,


Please verify that the pivot table name , and the field name are correct.


I have tried it out on a pivot table , and with the correct pivot table name and field name , I am not getting any error.


Narayan
 
Thanks Narayan.....have added a helper column with True false and used those in pivot to filter instead....


However, the fields name where perfect and the problem was only when the filtered values are date....anyways thanks for the assistance
 
Back
Top