【问题标题】:Clearing Power Pivot Slicers清除 Power Pivot 切片器
【发布时间】:2016-03-22 14:10:52
【问题描述】:

有没有人知道清除工作簿中切片器的好方法。 我有一张包含许多切片器的工作表,我想要一个按钮来清除它们。

我写了一点 VBA 来做到这一点但是有点慢

Sub ClearSlicers()
  Dim cache As SlicerCache

  For Each cache In ActiveWorkbook.SlicerCaches
           cache.ClearManualFilter
  Next cache
End Sub

只是想知道你有没有什么更漂亮的东西?

谢谢 约翰

【问题讨论】:

    标签: vba excel powerpivot slicers


    【解决方案1】:

    这将清除工作表中的所有切片器

    Sub test()
    
    Dim pt As PivotTable
    Dim cache As Slicer
    
    For Each pt In ActiveSheet.PivotTables
        For Each cache In pt.Slicers
            cache.SlicerCache.ClearAllFilters
        Next cache
    Next pt
    
    End Sub
    

    【讨论】:

    • 该代码不起作用,因为它们是 PowerPivot 切片器而不是数据透视表。我编写的代码有效,但需要大约 25 秒才能完成。我认为这是因为在清除每个过滤器后数据模型正在刷新。你知道停止这种刷新的方法吗?它让我发疯;-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    相关资源
    最近更新 更多