首页 > 解决方案 > 验证是否已经使用 VBA 创建了时间线

问题描述

我的电子表格中有一个timeline,但我想通过 VBA 代码验证时间线是否存在。

我如何检查是否有一个?

标签: excelvba

解决方案


时间线是 aSlicerCache和 a SlicerCacheTypexlTimeline

Sub FindTheTimeline()
    Dim cache As SlicerCache
    For Each cache In ThisWorkbook.SlicerCaches
        If cache.SlicerCacheType = xlTimeline Then
            Debug.Print "Got a timeline!"
            Exit Sub
        End If
    Next
End Sub

推荐阅读