Hi There
Im trying to follow along with MrExcel code to loop through slicers and produce PDF files, however Im getting error on the first section of the Code - Please see below the code I used from MrExcel.
It is erroring on the line 'For Each SI in scl.SlicerItems' with a Run-time error '1004': Application-defined or object defined error.
Hitting Debug, highlights the For Each line
Please let me know what I have done wrong as I can not move past this part to the rest of the code.
thank you!
Im trying to follow along with MrExcel code to loop through slicers and produce PDF files, however Im getting error on the first section of the Code - Please see below the code I used from MrExcel.
VBA Code:
Sub DoAllCombinations()
Dim sc1 As SlicerCache
Dim sc2 As SlicerCache
Dim SI As SlicerItem
Dim cell1 As Range
Dim cell2 As Range
Dim cell3 As Range
' These are the Slicer Names from the Slicer Settings Box
Set sc1 = ThisWorkbook.SlicerCaches("Slicer_Account_Name")
Set sc2 = ThisWorkbook.SlicerCaches("Slicer_Chart_Format4")
sc1.ClearAllFilters
sc2.ClearAllFilters
Ctr = 1
'Off to the right, build static lists of all Slicer Items
NextCol = ActiveSheet.UsedRange.Columns.Count + 2
RememberCol = NextCol
NextRow = 1
For Each SI In sc1.SlicerItems
Cells(NextRow, NextCol).Value = SI.Caption
NextRow = NextRow + 1
Next SI
LastRow = NextRow - 1
Cells(1, NextCol).Resize(LastRow, 1).Name = "SlicerItems1"
NextRow = 1
NextCol = NextCol + 1
For Each SI In sc1.SlicerItems
Cells(NextRow, NextCol).Value = SI.Caption
NextRow = NextRow + 1
Next SI
LastRow = NextRow - 1
Cells(1, NextCol).Resize(LastRow, 1).Name = "SlicerItems2"
Application.ScreenUpdating = False
End Sub
It is erroring on the line 'For Each SI in scl.SlicerItems' with a Run-time error '1004': Application-defined or object defined error.
Hitting Debug, highlights the For Each line
Please let me know what I have done wrong as I can not move past this part to the rest of the code.
thank you!