sashapixie
Board Regular
- Joined
- Aug 29, 2013
- Messages
- 71
- Office Version
- 365
- Platform
- Windows
Hello
I have two datasets:
I have a slicer for both datasets for contractor and i have a slicer for skill.
What i want to do is when the skill slicer is selected which in turn updates the contractor column / slicer in the pivot table to then reflect that change in the second dataset which does not have skill.
I have been trying to use this original code from Mr Excel but i keep getting a 1004 object defined error on the line For Each SI1 In sc1.SlicerItems
I have found so many forums with this solution but it seems to work for those and i cannot find anyone having the same error.
I would be really grateful for any help.
Thanks in advance.
I have two datasets:
Dataset 1 | Contractor | Skill |
Dataset 2 | Contractor | Project |
I have a slicer for both datasets for contractor and i have a slicer for skill.
What i want to do is when the skill slicer is selected which in turn updates the contractor column / slicer in the pivot table to then reflect that change in the second dataset which does not have skill.
I have been trying to use this original code from Mr Excel but i keep getting a 1004 object defined error on the line For Each SI1 In sc1.SlicerItems
VBA Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
'Declaring variables
Dim sc1 As SlicerCache
Dim sc2 As SlicerCache
Dim SI1 As SlicerItem
'These names come from Slicer Settings dialog box
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Contractor")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Contractor1")
'make the macro faster
Application.EnableEvents = False
Application.ScreenUpdating = False
'Clearing filters to mirror sc1
sc2.ClearManualFilter
'Getting error here
For Each SI1 In sc1.SlicerItems
sc2.SlicerItems(SI1.Name).Selected = SI1.Selected
Next SI1
'make the macro faster
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
I have found so many forums with this solution but it seems to work for those and i cannot find anyone having the same error.
I would be really grateful for any help.
Thanks in advance.