How to select all pivot items with .PivotItems(?????).Visible = True

BOYAR

New Member
Joined
Jul 14, 2016
Messages
4
Hi Everyone,

Im trying to find easy solution on how to select all Pivot items. Things is that my data base is updated with new entries very often so i need to refresh pivot and then open filters and click on "select all" each time, and then un-check "blanks"

What i have now is :

Code:
Sub Pivot_upd()
'
' Pivot_upd Macro
'

'
    Sheets("Pivot").Select
    ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
    With ActiveSheet.PivotTables("PivotTable2").PivotFields("Mfg. Part #")
        .PivotItems([B]"(Select ALL)"[/B]).Visible = True
        .PivotItems("(blank)").Visible = False
        
    End With
    
End Sub

Im not sure what is the proper command to be used instead of this "select all" ?
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Ok found the solution:

Code:
Sub Pivot_upd()
'
' Pivot_upd Macro
'

'
    Sheets("Pivot").Select
    ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
    With ActiveSheet.PivotTables("PivotTable2").PivotFields("Mfg. Part #")
        .ClearAllFilters
        .PivotItems("(blank)").Visible = False
                 
    End With
    
End Sub
 
Upvote 0
Thank you, Boyar. For some reason, when I tried recording the macro, I did not get that code. But, this time I did.

Still did not work like I wanted, but taking your suggestion I found the solution that works.

I have two pivot tables and created this sub which seems to do the job ...
  • Select all the items
  • Then de-select the pivot items that equal zero

VBA Code:
Sub RefeshPivots()

    Sheet4.PivotTables("PivotTable1").PivotCache.Refresh
        With Sheet4.PivotTables("PivotTable1").PivotFields("Years Total")
            .ClearAllFilters
            .PivotItems("$0").Visible = False
        End With
        
    Sheet4.PivotTables("PivotTable2").PivotCache.Refresh
        With Sheet4.PivotTables("PivotTable2").PivotFields("Years Total")
            .ClearAllFilters
            .PivotItems("$0").Visible = False
        End With

End Sub

Regards,

Steve
 
Upvote 0

Forum statistics

Threads
1,215,708
Messages
6,126,373
Members
449,311
Latest member
accessbob

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