Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

showing all pivot items in second column

Status
Not open for further replies.

t16turbo

Programmer
Mar 22, 2005
315
GB
hi all, I have searched this forum and ended up following a link which gives me:

Code:
Sub PivotShowItemAllVisible()
'sort is set to Manual to prevent errors, e.g.
'unable to set Visible Property of PivotItem class
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
For Each pt In ActiveSheet.PivotTables
   For Each pf In pt.VisibleFields
    pf.AutoSort xlManual, pf.SourceName
     For Each pi In pf.PivotItems
         pi.Visible = True
     Next pi
    pf.AutoSort xlAscending, pf.SourceName
   Next pf
Next pt
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

this only applies to the rows in the first pivot column in my table.
Can anyone tell me how I apply this to all pivot columns?
or a specified one?
 

I made only 2 changes. First i used PivotFields instead of VisibleFields. Second I used pvt, pvf, pvi instead of pi (pi is often used as a math constant)
Code:
Sub PivotShowItemAllVisible()
    'sort is set to Manual to prevent errors, e.g.
    'unable to set Visible Property of PivotItem class
    Dim pvt As PivotTable
    Dim pvf As PivotField
    Dim pvi As PivotItem
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    On Error Resume Next
    For Each pvt In ActiveSheet.PivotTables
       For Each pvf In pvt.PivotFields
        pvf.AutoSort xlManual, pvf.SourceName
         For Each pvi In pvf.PivotItems
             pvi.Visible = True
         Next pvi
        pvf.AutoSort xlAscending, pf.SourceName
       Next pvf
    Next pvt
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub


Skip,
[sub]
[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top