Hi All,
I'm trying to get a pivot table to filter on records that have a specific date tied to them. I want to reference a list of specific dates that I have on a separate sheet called "py calendar" - the list of dates are currently from A2:A27 on here, but can vary.
With sheet "Approvals" and pivot table being "PivotTable1"
Sub filterdates()
Dim PT As PivotTable
Dim PF As PivotField
Dim Sh As Worksheet
Dim Dates As Date
Set Sh = ThisWorkbook.Sheets("Approvals")
Set PT = Sh.PivotTables("PivotTable1")
Set PF = PT.PivotFields("Approval Date")
PT.ClearAllFilters
PF.PivotFilters.Add Type:=x1SpecificDate, Value1:this is what I'm not sure of
End Sub
Or I'm trying this:
Sub filter2()
Dim Dates As String
Dates = Worksheets("py calendar").Range("A:A").Value
Sheets("Approvals").PivotTables("PivotTable1").PivotFields("Approval Date").CurrentPage = Dates
End Sub
I'm trying to get a pivot table to filter on records that have a specific date tied to them. I want to reference a list of specific dates that I have on a separate sheet called "py calendar" - the list of dates are currently from A2:A27 on here, but can vary.
With sheet "Approvals" and pivot table being "PivotTable1"
Sub filterdates()
Dim PT As PivotTable
Dim PF As PivotField
Dim Sh As Worksheet
Dim Dates As Date
Set Sh = ThisWorkbook.Sheets("Approvals")
Set PT = Sh.PivotTables("PivotTable1")
Set PF = PT.PivotFields("Approval Date")
PT.ClearAllFilters
PF.PivotFilters.Add Type:=x1SpecificDate, Value1:this is what I'm not sure of
End Sub
Or I'm trying this:
Sub filter2()
Dim Dates As String
Dates = Worksheets("py calendar").Range("A:A").Value
Sheets("Approvals").PivotTables("PivotTable1").PivotFields("Approval Date").CurrentPage = Dates
End Sub