Deselect all items in a pivot table using vba

前端 未结 5 716
野的像风
野的像风 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 14:05

    This is how I do for custom filter selection. May be slower due to double looping.

    Dim toSelect(1 To 3) As String
    
    toSelect(1) = "item1"
    toSelect(2) = "item2"
    toSelect(3) = "item3"
    
    
    For Each pvItem In objField.PivotItems
        For Each st In toSelect
            If pvItem.Value = st Then
                pvItem.Visible = True
                Exit For
            Else
                pvItem.Visible = False
            End If
        Next
    Next
    

提交回复
热议问题