i want to be able to write some vba script so i can automate a pivot table based on "before" date filter which is linked to a specific cell reference in B2

the filter is called "Close date"

I am already setting another filter as follows:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'This line stops the worksheet updating on every change, it only updates when cell
'b1 or b2 is touched
If Intersect(Target, Range("B1:B2")) Is Nothing Then Exit Sub

'Set the Variables to be used
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String

'Here you amend to suit your data
Set pt = Worksheets("Summary").PivotTables("PivotTable1")
Set Field = pt.PivotFields("Quarter")
NewCat = Worksheets("Summary").Range("B1").Value

'This updates and refreshes the PIVOT table
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With


End Sub

many thanks