且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用vba取消选择数据透视表中的所有项目

更新时间:2023-01-31 20:02:41

这个可能是最接近你想要的:

  Dim i As Long 
.PivotItems(1)。 Visible = True
For i = 2 To .PivotItems.Count
.PivotItems(i).Visible = False
Next

这将使第一个选项成为唯一选择的选项(假设这是一个指向pivotfield的内容)。如果你知道你想要的手...修改相应的。


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:

.PivotItems("(Select All)").Visible = False

Thanks.

This is probably the closest you can get to what you want:

Dim i As Long
.PivotItems(1).Visible = True
For i = 2 To .PivotItems.Count
    .PivotItems(i).Visible = False
Next

This will make the very first option the only selected option (assuming this is within a with that points to the pivotfield). If you know what you want before hand... modify accordingly.