Jul 25 2023 10:34 AM
Hi,
I am using Excel 365; I created a slicer to filter my pivot table by date. I want to remove any dates before 1/1/2023 from the slicer. Is this possible?
The code that I have tried (it filters the dates from the pivot table but does not remove it from the slicer)
Sub FilterSlicer()
Dim sc As SlicerCache
Dim si As SlicerItem
Set sc = ActiveWorkbook.SlicerCaches("Slicer_Start_Month_Year")
For Each si In sc.SlicerItems
If InStr(si.Name, "2022") > 0 Or si.Name = "(blank)" Then
si.Selected = False
Else
si.Selected = True
End If
Next si
End Sub
Jul 25 2023 10:55 AM
Add a helper column to your data and check whether Date is >=01/01/2023.
Move the field into the pivot table or create a slicer and filter on TRUE.
Jul 25 2023 11:19 AM
Jul 25 2023 11:29 AM
Jul 26 2023 10:10 AM