错误424-“如果不是”行上的“需要对象”。
我已经尝试阅读此错误,但是我对SlicerCache不够熟悉,无法弄清楚这一错误-有人可以帮忙吗?
Dim dStartDate As Date
Dim dEndDate As Date
Dim sDateRange As String
Dim sDateRange_Num As String
Dim sDateRangeHeader As String
If Not ActiveWorbook.SlicerCaches("NativeTimeline_Date").FilterCleared = False Then
dStartDate = ActiveWorkbook.SlicerCaches("NativeTimeline_Date").TimelineState.FilterValue1
dEndDate = ActiveWorkbook.SlicerCaches("NativeTimeline_Date").TimelineState.FilterValue2
sDateRange = dStartDate & " - " & dEndDate
sDateRangeHeader = "Reporting Period: " & sDateRange & " (" & dEndDate - dStartDate & " Days)"
sDateRange_Num = dEndDate - dStartDate
Else
dStartDate = WorksheetFunction.Min(Range("D1:D100"))
dEndDate = WorksheetFunction.Max(Range("D1:D100"))
sDateRange = dStartDate & " - " & dEndDate
sDateRangeHeader = "Reporting Period: " & sDateRange & " (" & dEndDate - dStartDate & " Days)"
sDateRange_Num = dEndDate - dStartDate
End If
答案 0 :(得分:1)
您需要在k
中输入ActiveWorkbook
。始终使用模块顶部的Option Explicit
来捕获这些错误。
ActiveWorkbook.SlicerCaches("NativeTimeline_Date").FilterCleared