• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Code: Pivot Table Field Update Using Dropdown List

jdppep

Member
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

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
 
Is Specialty2 set as a Page/Report filter?
Is the value of H5 a legitimate choice?
If trying to do All, remember to include parenthesis "(All)"
 
Back
Top