Let's imagine that we have a slicer with over 1000 items and it keeps growing every day. I'm looking for a solution that I can select only 1 item out of a thousand without scrolling and finding my desired item. The way I see this is like a toggle, where you can turn ON/OFF for a particular item. When you Turn ON - Only that item is selected; when you turn OFF - Slicer filter is cleared.
I tried to record the macro but it will be a thousand lines of code where the slicer items are triggered either True or False, which I don't think will work given that the list is growing everyday.
Thank you for your supports!
Tony
May be bellow code is useful, also can you give an example.
Sub TestFilter()
Const FilterCol1 = 4 '........... Your target column
Const Criteria1 = "something" '.. Your target value
Dim LastRow As Integer
Dim LastCol As String
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
With ActiveSheet
LastRow = .Range("A" & .Rows.Count).End(xlUp).row
LastCol = Split(.Range("A1").End(xlToRight).Address, "$")(1)
.Range("A1" & ":" & LastCol & LastRow).AutoFilter field:=FilterCol1, Criteria1:=Criteria1
End With
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.