I have this macro to run in my workbook but is giving me an error, as a runtime 5 and it was working good in another computer but if I try in my is not working, this macro will filter everything for today's date only
Sub CreditCard()
Application.ScreenUpdating = False
Dim DueDate As String
Dim SlicerMonth As String
DueDate = Format(Date, "dd/mm/yyyy")
SlicerMonth = Format(Date, "mmmm-yy")
Call unselectAllBut("Slicer_Type1", "CREDIT CARD")
Call unselectAllBut("Slicer_Status1", "Open")
Call unselectAllBut("Slicer_MONTH1", SlicerMonth)
Call unselectAllBut("Slicer_Due1", DueDate)
Application.ScreenUpdating = True
End Sub
Sub Withdrawn()
Application.ScreenUpdating = False
Dim DueDate As String
Dim SlicerMonth As String
DueDate = Format(Date, "dd/mm/yyyy")
SlicerMonth = Format(Date, "mmmm-yy")
Call unselectAllBut("Slicer_Type", "Withdrawn")
Call unselectAllBut("Slicer_Status", "Open")
Call unselectAllBut("Slicer_MONTH", SlicerMonth)
Call unselectAllBut("Slicer_Due", DueDate)
Application.ScreenUpdating = True
End Sub
Public Sub unselectAllBut(slicerName As String, newSelection As String)
Dim WB As Workbook
Set WB = Workbooks("EFT_Report_Macro.xlsm")
WB.SlicerCaches(slicerName).SlicerItems(newSelection).Selected = True this line is show as yellow
Dim slc As SlicerItem
Dim slcr As SlicerCache
Dim slc1 As Slicer
For Each slc In ActiveWorkbook.SlicerCaches(slicerName).SlicerItems
If Not slc.Caption = newSelection Then
slc.Selected = False
End If
Next slc
End Sub
Sub CreditCard()
Application.ScreenUpdating = False
Dim DueDate As String
Dim SlicerMonth As String
DueDate = Format(Date, "dd/mm/yyyy")
SlicerMonth = Format(Date, "mmmm-yy")
Call unselectAllBut("Slicer_Type1", "CREDIT CARD")
Call unselectAllBut("Slicer_Status1", "Open")
Call unselectAllBut("Slicer_MONTH1", SlicerMonth)
Call unselectAllBut("Slicer_Due1", DueDate)
Application.ScreenUpdating = True
End Sub
Sub Withdrawn()
Application.ScreenUpdating = False
Dim DueDate As String
Dim SlicerMonth As String
DueDate = Format(Date, "dd/mm/yyyy")
SlicerMonth = Format(Date, "mmmm-yy")
Call unselectAllBut("Slicer_Type", "Withdrawn")
Call unselectAllBut("Slicer_Status", "Open")
Call unselectAllBut("Slicer_MONTH", SlicerMonth)
Call unselectAllBut("Slicer_Due", DueDate)
Application.ScreenUpdating = True
End Sub
Public Sub unselectAllBut(slicerName As String, newSelection As String)
Dim WB As Workbook
Set WB = Workbooks("EFT_Report_Macro.xlsm")
WB.SlicerCaches(slicerName).SlicerItems(newSelection).Selected = True this line is show as yellow
Dim slc As SlicerItem
Dim slcr As SlicerCache
Dim slc1 As Slicer
For Each slc In ActiveWorkbook.SlicerCaches(slicerName).SlicerItems
If Not slc.Caption = newSelection Then
slc.Selected = False
End If
Next slc
End Sub