Class TimelineState (Excel VBA)

The timeline-specific state of a SlicerCache object.

Item

To use a TimelineState class variable it first needs to be instantiated, for example

Dim tse as TimelineState
Set tse = ActiveWorkbook.SlicerCaches(1).TimelineState

TimelineState class variables can be set using the SlicerCache.TimelineState procedure.

EndDate

Returns the end of the filtering date range (equal to the StartDate property if range is a single day). Read-only Variant.

This property returns an error for either of the following conditions:

Dim dtEndDate As Date
dtEndDate = ActiveWorkbook.SlicerCaches(1).TimelineState.EndDate

FilterType

Returns the type of date filter.

xlAfter - Filters for all dates after a specified date, xlAfterOrEqualTo - Filters for all dates on or after a specified date, xlAllDatesInPeriodApril - Filters for all dates in April, xlAllDatesInPeriodAugust - Filters for all dates in August, xlAllDatesInPeriodDecember - Filters for all dates in December, xlAllDatesInPeriodFebruary - Filters for all dates in February, xlAllDatesInPeriodJanuary - Filters for all dates in January, xlAllDatesInPeriodJuly - Filters for all dates in July, xlAllDatesInPeriodJune - Filters for all dates in June, xlAllDatesInPeriodMarch - Filters for all dates in March, xlAllDatesInPeriodMay - Filters for all dates in May, xlAllDatesInPeriodNovember - Filters for all dates in November, xlAllDatesInPeriodOctober - Filters for all dates in October, xlAllDatesInPeriodQuarter1 - Filters for all dates in Quarter1, xlAllDatesInPeriodQuarter2 - Filters for all dates in Quarter2, xlAllDatesInPeriodQuarter3 - Filters for all dates in Quarter3, xlAllDatesInPeriodQuarter4 - Filters for all dates in Quarter 4, xlAllDatesInPeriodSeptember - Filters for all dates in September, xlBefore - Filters for all dates before a specified date, xlBeforeOrEqualTo - Filters for all dates on or before a specified date, xlBottomCount - Filters for the specified number of values from the bottom of a list, xlBottomPercent - Filters for the specified percentage of values from the bottom of a list, xlBottomSum - Sum of the values from the bottom of the list, xlCaptionBeginsWith - Filters for all captions beginning with the specified string, xlCaptionContains - Filters for all captions that contain the specified string, xlCaptionDoesNotBeginWith - Filters for all captions that do not begin with the specified string, xlCaptionDoesNotContain - Filters for all captions that do not contain the specified string, xlCaptionDoesNotEndWith - Filters for all captions that do not end with the specified string, xlCaptionDoesNotEqual - Filters for all captions that do not match the specified string, xlCaptionEndsWith - Filters for all captions that end with the specified string, xlCaptionEquals - Filters for all captions that match the specified string, xlCaptionIsBetween - Filters for all captions that are between a specified range of values, xlCaptionIsGreaterThan - Filters for all captions that are greater than the specified value, xlCaptionIsGreaterThanOrEqualTo - Filters for all captions that are greater than or match the specified value, xlCaptionIsLessThan - Filters for all captions that are less than the specified value, xlCaptionIsLessThanOrEqualTo - Filters for all captions that are less than or match the specified value, xlCaptionIsNotBetween - Filters for all captions that are not between a specified range of values, xlDateBetween - Filters for all dates that are between a specified range of dates, xlDateLastMonth - Filters for all dates that apply to the previous month, xlDateLastQuarter - Filters for all dates that apply to the previous quarter, xlDateLastWeek - Filters for all dates that apply to the previous week, xlDateLastYear - Filters for all dates that apply to the previous year, xlDateNextMonth - Filters for all dates that apply to the next month, xlDateNextQuarter - Filters for all dates that apply to the next quarter, xlDateNextWeek - Filters for all dates that apply to the next week, xlDateNextYear - Filters for all dates that apply to the next year, xlDateNotBetween, xlDateThisMonth - Filters for all dates that apply to the current month, xlDateThisQuarter - Filters for all dates that apply to the current quarter, xlDateThisWeek - Filters for all dates that apply to the current week, xlDateThisYear - Filters for all dates that apply to the current year, xlDateToday - Filters for all dates that apply to the current date, xlDateTomorrow - Filters for all dates that apply to the next day, xlDateYesterday - Filters for all dates that apply to the previous day, xlNotSpecificDate - Filters for all dates that do not match a specified date, xlSpecificDate - Filters for all dates that match a specified date, xlTopCount - Filters for the specified number of values from the top of a list, xlTopPercent - Filters for the specified percentage of values from a list, xlTopSum - Sum of the values from the top of the list, xlValueDoesNotEqual - Filters for all values that do not match the specified value, xlValueEquals - Filters for all values that match the specified value, xlValueIsBetween - Filters for all values that are between a specified range of values, xlValueIsGreaterThan - Filters for all values that are greater than the specified value, xlValueIsGreaterThanOrEqualTo - Filters for all values that are greater than or match the specified value, xlValueIsLessThan - Filters for all values that are less than the specified value, xlValueIsLessThanOrEqualTo - Filters for all values that are less than or match the specified value, xlValueIsNotBetween - Filters for all values that are not between a specified range of values, xlYearToDate - Filters for all values that are within one year of a specified date.
Dim xpfFilterType As XlPivotFilterType
xpfFilterType = ActiveWorkbook.SlicerCaches(1).TimelineState.FilterType

FilterValue1

Returns the first value associated with the date filter (semantics vary by filter type).

Dim varFilterValue1 As Variant
varFilterValue1 = ActiveWorkbook.SlicerCaches(1).TimelineState.FilterValue1

FilterValue2

Returns the second value associated with the date filter (semantics vary by filter type).

Dim varFilterValue2 As Variant
varFilterValue2 = ActiveWorkbook.SlicerCaches(1).TimelineState.FilterValue2

SetFilterDateRange

Sets the timeline's filter.

xlFilterStatusDateHasTime - SetFilterDateRange(?): StartDate or EndDate have a time portion, xlFilterStatusDateWrongOrder - SetFilterDateRange(?): StartDate > EndDate, xlFilterStatusInvalidDate - SetFilterDateRange(?): StartDate or EndDate are not valid dates, xlFilterStatusOK - Signifies OK or successful.

SetFilterDateRange (StartDate, EndDate)

Dim dtStartDate As Date: dtStartDate = 
Dim dtEndDate As Date: dtEndDate = 
Dim xfssSetFilterDateRange As XlFilterStatus
xfssSetFilterDateRange = ActiveWorkbook.SlicerCaches(1).TimelineState.SetFilterDateRange(StartDate:=dtStartDate, EndDate:=dtEndDate)

Arguments

The following arguments are required:

StartDate - The start of the filtering date range

EndDate - The end of the filtering date range

SingleRangeFilterState

True when the filtering state is a contiguous date range; otherwise, False.

Dim booSingleRangeFilterState As Boolean
booSingleRangeFilterState = ActiveWorkbook.SlicerCaches(1).TimelineState.SingleRangeFilterState

StartDate

Returns the start of the filtering date range. Read-only Variant.

This property returns an error for either of the following conditions:

Dim dtStartDate As Date
dtStartDate = ActiveWorkbook.SlicerCaches(1).TimelineState.StartDate