简体   繁体   English

在切片器中循环遍历过滤的项目

[英]Looping through filtered items in slicer

I am attempting to write a macro but am caught up. 我试图写一个宏,但是被赶上了。 How do you create a loop that will loop through only visible objects in an already filtered slicer. 如何创建一个循环,该循环将仅循环通过已过滤的切片器中的可见对象。

Image below is the slicer I want to use ("slicer_Route") and I only the loop to loop through the first 4 darkened objects. 下图是我要使用的切片器(“ slicer_Route”),我只循环了前四个暗对象。 (These were the result of another filter) (这些是另一个过滤器的结果)

SLICER: 切片器:

在此处输入图片说明

I don't know what you want to do but this goes through Visible Items: 我不知道您想做什么,但这贯穿于可见项目:

Dim sC As SlicerCache
Dim sI As SlicerItem

Set sC = ActiveWorkbook.SlicerCaches("Slicer_Route")

For Each sI in sC.SlicerItems
If sI.Selected = True Then

Debug.Print sI.Name 'This is an example, you can do what you want with that item

End If

Next sI

If you provide more detailed question, you may get further help. 如果您提供更详细的问题,则可能会得到进一步的帮助。

您可以通过在sliceritems中使用属性HasData来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM