Slicer multiple selection keeps throwing error

Michael36

New Member
Joined
Feb 17, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I've been trying to make a selection on a range in one page and then put the values of that array in a slicer on an other page. I've been looking into the answers provided, but the program keeps throwing error 1004 at me in the code line For Each item In .SlicerItems. I've then tried putting in the "hard" text values , but still nothing.
Any help would be appreciated!

VBA Code:
Sub SlicerUpdate()
 

Dim wb As Workbook
Dim dbWS As Worksheet
Dim dbWS2 As Worksheet
Dim lbText As String
Dim vItems As Variant
Dim vMatchVal As Variant
Dim item As SlicerItem

Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
    
    Set wb = ThisWorkbook
    Set dbWS = Sheets("Voortgang kosten in tijd")
    
Sheets("Realisatie NoPMO TFT per proj").Select
vItems = Selection.Range("a2:A5")
Sheets("Voortgang kosten in tijd").Select

    'vItems = "330521"
    lbText = "330521"
    ActiveSheet.Shapes.Range(Array("Rimses werkorder code")).Select
    With wb.SlicerCaches("Slicer_Rimses_werkorder_code")
        .ClearManualFilter
        [COLOR=rgb(184, 49, 47)]For Each item In .SlicerItems[/COLOR]
            vMatchVal = Application.Match(item.Name, vItems, 0)
            If IsError(vMatchVal) Then
                item.Selected = False
            End If
        Next item
    End With

Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlAutomatic




End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top