Iterate over slicer via VBA and select a single item each time

前端 未结 3 2034
不知归路
不知归路 2020-11-30 15:48

I have several slicers within a spreadhseet. I\'d like to be able to loop over one of these via VBA, and select every option one by one. The macro below seems fine to my ti

3条回答
  •  清歌不尽
    2020-11-30 16:31

    You can indeed have several selected items within an excel spreadsheet. The code you posted do nothing instead of selecting all items satisfying slDummy.Name = slItem.Name.

    If I understand well, you want to run some code once the item is selected, and then go to the next item. You can achieve this by unselecting one item after use, with item.selected = False.

    You may also want to select all items needed at first stage and then run a loop that will afect only the item that have the property .selected set to true. However it will probably be longer to execute as you'd have one more loop.

提交回复
热议问题