需要 VBA 代码才能取消选择所有切片器项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22372880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 02:19:17 来源:igfitidea点击:
Need VBA Code for Deselect all slicer items
提问by Pravi
ActiveWorkbook.SlicerCaches("Slicer_xxxxx").ClearManualFilter
I need to deselect all slicer items. I tried this
我需要取消选择所有切片器项目。我试过这个
For i = 1 To numberOfItems
On Error Resume Next
.SlicerItems(i).Selected = False
Next i
Please help
请帮忙
回答by Cuong Ngo Hung
Public Sub unselectAllBut(slicerName As String, newSelection As String)
ThisWorkbook.SlicerCaches(slicerName).SlicerItems(newSelection).Selected = True
Dim slc As SlicerItem
For Each slc In ThisWorkbook.SlicerCaches(slicerName).SlicerItems
If Not slc.Caption = newSelection Then
slc.Selected = False
End If
Next slc
End Sub
Try this! :)
尝试这个!:)
Ex: unselectAllBut(UrSlicerName, Item's caption u want to select)
例如:unselectAllBut(UrSlicerName, 您要选择的项目标题)