Hi all, I Have this code below looking at a specific cell, based on the name in that cell X7 (also stated as New Cat), The code selects that same name in the pivot table filter (Resource Pool Name).
By selecting this name the pivot itself displays data that is tied to this name.
Problem: If the name in X7 (New Cat) is not in the pivot, the code just shows all data for all Resource Pool Names (no Filter at all)
How do I update my code to do what it's doing but if the name in x7 does not exist in the pivot to just select "blank"
in the Resource Pool Name filter
'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("ENG").PivotTables("ENGDmd") Set Field = pt.PivotFields("Resource Pool Name") NewCat = Worksheets("ENG").Range("x7").Value If NewCat = "" Then Exit Sub End If 'This updates and refreshes the PIVOT table With pt Field.ClearAllFilters Field.CurrentPage = NewCat End With
Bookmarks