Hello friends,

I have a pivottable that has 3 report filters:
1. Year
2. year of eoc
3. month of eoc

I want a macro that will change the filters according to the values entered in the following cells (respectively):
A. Sheet Attendance – cell H2
B. Sheet Attendance – cell H3
C. Sheet Attendance – cell AM2
I made the following macro but it is not working, please fix it, or make a better one please.
Anything goes as long as the macro auto changes the report filters.

Thanks a lot in advance.

Sub pt()
Sheets("Attendance").Select
  
'Set the Variables to be used
Dim pt As PivotTable
Dim pt2 As PivotTable
Dim pt3 As PivotTable

Dim Field As PivotField

Dim NewCat As String
Dim NewDOG As String
Dim NewBAT As String

'Here you amend to suit your data
Set pt = Worksheets("Calculations").PivotTables("PivotTable1")
Set Field = pt.PivotFields("year")
NewCat = Worksheets("Attendance").Range("H2").Value

Set pt2 = Worksheets("Calculations").PivotTables("PivotTable1")
Set Field = pt.PivotFields("Attendance")
NewDOG = Worksheets("Attendance").Range("H3").Value

Set pt3 = Worksheets("Calculations").PivotTables("PivotTable1")
Set Field = pt.PivotFields("month of eoc")
NewBAT = Worksheets("Attendance").Range("AM2").Value



'This updates and refreshes the PIVOT table
With pt And pt2 And pt3
Field.ClearAllFilters
Field.CurrentPage = NewCat
Field.CurrentPage = NewDOG
Field.CurrentPage = NewBAT

pt.RefreshTable
pt2.RefreshTable
pt3.RefreshTable

End With
End Sub