Pivotfilter with variations of similar item

muhleebbin

Active Member
Joined
Sep 30, 2017
Messages
252
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Hi,

Can someone help me with the following code?

VBA Code:
Sub refreshpivot()

Dim ws As Worksheet
Dim pvt As PivotTable
Dim pf As PivotField
Set pvt = Worksheets("GL R Pivot").PivotTables("PivotTable1")
Set pf = pvt.PivotFields("Person/Description")

Application.ScreenUpdating = False
ThisWorkbook.RefreshAll

    On Error Resume Next
    With pf
        .ClearAllFilters
        .PivotItems("(blank)").Visible = False
        .PivotItems("").Visible = False
        .PivotItems("Net Change").Visible = False
    End With

Application.ScreenUpdating = True

End Sub

The issue i'm having is that "Net Change" item is really "Net Change = -#####", is it possible so that it finds any and all instances of the "Net Change" item?

Thanks in advance for your assistance
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Solved it with

VBA Code:
Sub refreshpivot()

Dim ws As Worksheet
Dim pvt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Dim str As String
Set pvt = Worksheets("GL R Pivot").PivotTables("PivotTable1")
Set pf = pvt.PivotFields("Person/Description")
str = "Net Change"

Application.ScreenUpdating = False
ThisWorkbook.RefreshAll

    On Error Resume Next
    With pf
        .ClearAllFilters
            For Each pi In .PivotItems
                If pi.Name Like "*" & str & "*" Then
                    pi.Visible = False
                Else
                    pi.Visible = True
                End If
            Next pi
        .PivotItems("(blank)").Visible = False
        .PivotItems("").Visible = False
    End With

Application.ScreenUpdating = True

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top