rob_grimshaw
New Member
- Joined
- Jan 18, 2019
- Messages
- 9
Hi, all,
I'm writing VBA that filters the CurrentPage on an existing PivotTable based on today's date, but it isn't working - any ideas? The source data are in a date format.
Many thanks.
I'm writing VBA that filters the CurrentPage on an existing PivotTable based on today's date, but it isn't working - any ideas? The source data are in a date format.
VBA Code:
Set pt = ThisWorkbook.Worksheets(1).PivotTables(1)
With pt
.ManualUpdate = True
.PivotCache.Refresh
.RefreshTable
With .PivotFields("Date")
.ClearAllFilters
' * None of these work! * - I've tried them all for good measure!
.CurrentPage = "26/10/2020"
.PivotFilters.Add Type:=xlSpecificDate, Value1:="26/10/2020"
.PivotFilters.Add Type:=xlDateToday
.PivotFilters.Add Type:=xlCaptionEquals, Value1:="26/10/2020"
.PivotFilters.Add Type:=xlValueEquals, Value1:="26/10/2020"
End With
.ManualUpdate = False
End With
Many thanks.