This is what I'm trying to do : I would like a new copy of my Excel file to be saved for each item (individually) in my slicer when running my macro. The problem is that every time I run it, there is something wrong with my For Loop here "For Each slItem In slBox.SlicerItems" that I don't understand. The error is : Run-time error '1004': Apllication-defined or object-defined error. YRl37.png

Option Explicit

Sub SavingData()


Dim Folder As Workbook
Dim NewFolderName As String
Dim ReportFolder As String
Dim slItem As SlicerItem
Dim slDummy As SlicerItem
Dim slBox As SlicerCache

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Set Folder = ActiveWorkbook
    Set slBox = ActiveWorkbook.SlicerCaches("Slicer_Regroupement_SousR")
    ReportFolder = Folder.Sheets("Variables").Range("FileName").Value
    ActiveWorkbook.Worksheets("Pilotage").Activate
    
    
    ChDir ReportFolder

    'loop through each slicer item
    For Each slItem In slBox.SlicerItems

        'clear all items to start
        slBox.ClearManualFilter
        
        'test each item against itself
        For Each slDummy In slBox.SlicerItems

            'if the item equals the item in the first loop, then select it
            'otherwise don't show it (thus showing 1 at a time between the nested loops)
            If slItem.Name = slDummy.Name Then slDummy.Selected = True Else: slDummy.Selected = False
    

        Next slDummy
        
            NewFolderName = Folder.Sheets("Variables").Range("ReportName").Value
            
            ActiveWorkbook.SaveAs Filename:=ReportFolder & "\" & NewFolderName _
            , FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
            
    Next slItem
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub