Hello
I have a kind of similar problem, for which I am using the below code, becasue I dont need to select date range for all Pivots, but only for one pivot. May be you can advice me what change required in your script only, as my script and your script gives the same result but my script shows a debug error.
The problem is that, date ranges that I want are getting selected, but it is also selecting few other dates as well, dont know why? Please help.
Sub MultiItemPivotFilter()
Const StartDate As Date = #5/1/2012#
Const EndDate As Date = #5/31/2012#
Dim pi As PivotItem
For Each pi In ActiveSheet.PivotTables("PivotTable2").PivotFields("Date Logged").PivotItems
If DateValue(pi.Name) < StartDate Or DateValue(pi.Name) > EndDate Then
Debug.Print DateValue(pi.Name), StartDate, EndDate
pi.Visible = False
Else
pi.Visible = True
End If
Next pi
End Sub
Bookmarks