Forum Discussion

Daniella1580's avatar
Daniella1580
Copper Contributor
Apr 12, 2024

Pivot table filters

When you right click on a pivot table row and select keep selected items it let's you do this by highlighting certain rows that aren't consecutive. If you select non consecutive rows and right click and do hide selected items it doesn't work. Why is this or is it just a problem my end? Thanks 

  • Sub HideSelectedItems()
    Dim pvt As PivotTable
    Dim pvtField As PivotField
    Dim item As PivotItem

    Set pvt = ActiveSheet.PivotTables(1) ' Adjust index as needed
    Set pvtField = pvt.PivotFields("YourFieldName") ' Adjust field name as needed

    For Each item In pvtField.PivotItems
    If Not item.Visible Then
    item.Visible = False
    End If
    Next item
    End Sub

Share

Resources