PivotTable currentpage date filter

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.

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.
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Watch MrExcel Video

Forum statistics

Threads
1,118,886
Messages
5,574,834
Members
412,620
Latest member
sharma7s
Top