如何修复此 SlicerCache 对象错误?
How do I fix this SlicerCache object error?
错误 424 - "Object required" 在 "If Not" 行。
我已尝试阅读此错误,但我对 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
您需要 k
ActiveWorkbook
。始终在模块顶部使用 Option Explicit
来捕获这些错误。
ActiveWorkbook.SlicerCaches("NativeTimeline_Date").FilterCleared
错误 424 - "Object required" 在 "If Not" 行。
我已尝试阅读此错误,但我对 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
您需要 k
ActiveWorkbook
。始终在模块顶部使用 Option Explicit
来捕获这些错误。
ActiveWorkbook.SlicerCaches("NativeTimeline_Date").FilterCleared