jeudi 16 avril 2020

Is there any VBA code in excel for checkboxes to do operation when you select it and redo the operation when you deselect it .?

i have a checkbox named check box 2 , it acts as a slicer for the pivot table

enter image description here

so when i select the check box it filter the pivot table ,but when i deselect the check box the data in the pivot table is still filterd out.it didnt come back to the original state as it was before selecting the checkbox i have tried changing the vba code using if then else but didnt find a way to populate it please help me with this code below is the code

Sub Red_macro()
'
' Red_macro Macro

    With ActiveWorkbook.SlicerCaches("Slicer_Cash_Collection_Score")
        .SlicerItems("Red").Selected = True
        .SlicerItems("Amber").Selected = False
        .SlicerItems("EFT").Selected = False
        .SlicerItems("Green").Selected = False
    End With
    ActiveWindow.SmallScroll Down:=-3
End Sub

what i was planning to do is if i select the check box it should filter the data and if deselect the checkbox it should unfilter the data .




Aucun commentaire:

Enregistrer un commentaire