My purpose: In a sheet of my file, there is a list of checkboxes that I can check in order to select specific sliceritems of the slicer 'A' located in another sheet of my file.
I succeeded to write a code in order select a slicer item of the slicer 'A' once I have selected the checkbox (for example when I click in the checkboxe 'RD' it select the slicer item 'RD' in the slicer 'A')
However, I can't select multiple slicer items of one slicer with dthe checkboxes
I tried to write a code to select one slicer item at once and it's working. When I click on a checkboxe in my sheet 'Report', the item of a slicer in a worksheet of my workbook is well selected
I tried this code
Sub CheckBox105_Click()
Dim sC As SlicerCache Dim department(0 To 21) As Variant
Set sC = ThisWorkbook.SlicerCaches("Slicer_Department")
Application.EnableEvents = False
For i = 0 To 21 department(i) = sC.SlicerItems(i + 1).Name Next i
sC.VisibleSlicerItemsList = department
sC.SlicerItems("RR").Selected = True
sC.SlicerItems("FD").Selected = False
sC.SlicerItems("HG").Selected = False
sC.SlicerItems("BP").Selected = False
sC.SlicerItems("HH").Selected = False
sC.SlicerItems("CO").Selected = False
sC.SlicerItems("CO").Selected = False
sC.SlicerItems("YH").Selected = False
sC.SlicerItems("LI").Selected = False
sC.SlicerItems("ED").Selected = False
sC.SlicerItems("FI").Selected = False
sC.SlicerItems("GM").Selected = False
sC.SlicerItems("GU").Selected = False
sC.SlicerItems("HR").Selected = False
sC.SlicerItems("IT").Selected = False
sC.SlicerItems("LE").Selected = False
sC.SlicerItems("OP").Selected = False
sC.SlicerItems("RK").Selected = False
sC.SlicerItems("SRG").Selected = False
sC.SlicerItems("BRM").Selected = False
sC.SlicerItems("DT").Selected = False
sC.SlicerItems("IC").Selected = False
sC.SlicerItems("(blank)").Selected = False
Application.EnableEvents = True
With this code, the result that I expect is the following one: I select the checkboxe105 and it select the slicer item 'RD' I select the checkoxe106 and it select the slicer item 'FD' and keep the first slicer item 'RD' selected
Aucun commentaire:
Enregistrer un commentaire