Hi There Hoping someone can help troubleshoot my code
Getting this error:
Compile Error : Method or Data Error not Found
I'm using the the latest version of Excel 64 bit
The goal of the code is to take the date in cell A2 and then automatically select the corresponding date in the slicers that have a source name of "Week End" and the previous 5 dates
Getting this error:
Compile Error : Method or Data Error not Found
I'm using the the latest version of Excel 64 bit
The goal of the code is to take the date in cell A2 and then automatically select the corresponding date in the slicers that have a source name of "Week End" and the previous 5 dates
VBA Code:
Sub SelectSlicerValues()
Dim ws As Worksheet
Dim slicerCaches As SlicerCaches
Dim slicerCache As SlicerCache
Dim dateValue As Date
Dim dateList As String
Dim i As Integer
Set ws = ActiveWorkbook.Worksheets("Sheet1")
If Not ws Is Nothing Then
Set slicerCaches = ws.SlicerCaches
If slicerCaches.Count > 0 Then
dateValue = ws.Range("A2").Value
dateList = Format(dateValue - 6, "m/d/yyyy") & ":" & Format(dateValue, "m/d/yyyy")
For Each slicerCache In slicerCaches
If slicerCache.SourceName = "Week End" Then
slicerCache.ClearManualFilter
slicerCache.VisibleSlicerItemsList = Array(dateList)
End If
Next slicerCache
Else
MsgBox "This worksheet doesn't contain any slicers.", vbExclamation, "No Slicers Found"
End If
Else
MsgBox "Worksheet not found.", vbCritical, "Error"
End If
End Sub
Last edited by a moderator: