I am trying to update a pivot table field using a dropdown list. The code I have is below.
I receive the following error when attempting: Run-time error '1004' Unable to set the CurrentPage property of the PivotField class
Any help is appreciated!
Thanks,
Jared
I receive the following error when attempting: Run-time error '1004' Unable to set the CurrentPage property of the PivotField class
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("H5")) Is Nothing Then Exit Sub
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String
Set pt = Worksheets("P2").PivotTables("SpecialtyPivot")
Set Field = pt.PivotFields("Specialty2")
NewCat = Worksheets("P2").Range("H5").Value
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With
End Sub
Any help is appreciated!
Thanks,
Jared