Sena
Sena

Reputation: 31

Verify if Timeline is already created with VBA

I have a timeline in my spreadsheet but I want to verify if the timeline exists via VBA code.

How do I check if there's one?

Upvotes: 0

Views: 157

Answers (1)

BigBen
BigBen

Reputation: 49998

A timeline is a SlicerCache with a SlicerCacheType of xlTimeline:

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

Upvotes: 3

Related Questions