Deselect all items in a pivot table using vba

前端 未结 5 752
野的像风
野的像风 2021-01-12 13:43

Can some quicly explain the way to deselect all items in a newly created pivot table so that I can go back and select only one or two items? I tried the following:



        
5条回答
  •  醉酒成梦
    2021-01-12 13:48

    Well.

    Because you have not how to hide all, because, always you need to have 1 item visible

    I do this:

    I start hiding the first field, and before go to the next, i show all fields i need visible, then, i go to the secont item, and hide, and again show all items i want, and so on. Then, always will be visible any field, and wont have error.

    After the loop, i again try to show all fields i want.

    With ActiveSheet.PivotTables("TablaD2").PivotFields("Entity")

        Dim i As Long
    
        For i = 1 To .PivotItems.Count
    
        .PivotItems(i).Visible = False
    
        .PivotItems("ARG").Visible = True
        .PivotItems("BRL").Visible = True
        .PivotItems("GCB").Visible = True
        .PivotItems("MEX").Visible = True
        Next
        .PivotItems("ARG").Visible = True
        .PivotItems("BRL").Visible = True
        .PivotItems("GCB").Visible = True
        .PivotItems("MEX").Visible = True
    
    
    
    End With
    

提交回复
热议问题