I'm trying to hide pivot items containg a keyword. For example, if the pivot item contains the word 'CREDIT', I want to hide/deselect that row. I think the following code is close but it's not working. Any help is appreciated. (currently it cycles through all the pivot items but doesn't hide any of the rows where the word credit appears)
Hide Pivot Items by Keyword
-
-
-
Re: Hide Pivot Items by Keyword
See if this does what you want.
Code
Display MoreSub HidePivotItems() Dim pt As PivotTable, pi As PivotItem Set pt = ActiveSheet.PivotTables("PivotTable1") For Each pi In pt.PivotFields("Agency").PivotItems If pi.Name = "CREDIT" Then pi.Visible = False Else pi.Visible = True End If Next pi End Sub
HTH Cheers
-
Re: Hide Pivot Items by Keyword
I'll try that but it looks like it's only going to hide items with that exact name....I want to hide any row containing that keyword appearing in the name/pivot item
-
-
Re: Hide Pivot Items by Keyword
That worked. Thank you!
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!