I'd like to run a macro which will update to extracts by selecting today()-1 in slicers with Macro. But I can't get it work.
I've tried to get date from cell value, and tried with Date and Now functions too. None of them worked. Anyone with any idea?
I get:
Sub Update_date()
'
' Update_date Macro
'
Dim MyDate As Range
Set MyDate = ThisWorkbook.Worksheets("Slicers").Range("D2")
'
ActiveWorkbook.SlicerCaches("Slicer_Ship_Date").VisibleSlicerItemsList = Array _
( _
"[Sales Orders].[Ship Date].MyDate")
ActiveWorkbook.SlicerCaches("Slicer_Ship_Date1").VisibleSlicerItemsList = Array _
( _
"[Sales Orders].[Ship Date].MyDate")
End Sub
Sub Update_date()
'
' Update_date Macro
'
'
' Update_date Macro
'
Dim MyDate As Range
Dim MyDate2
Set MyDate = ThisWorkbook.Worksheets("Slicers").Range("D2")
MyDate2 = Format(MyDate, "yyyy-MM-ddTHH:mm:ss")
'
ActiveWorkbook.SlicerCaches("Slicer_Ship_Date").VisibleSlicerItemsList = Array _
( _
"[Sales Orders].[Ship Date].&[" & MyDate2 & "]")
ActiveWorkbook.SlicerCaches("Slicer_Ship_Date1").VisibleSlicerItemsList = Array _
( _
"[Sales Orders].[Ship Date].&[" & MyDate2 & "]")
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.