Bonjour Fred
je fais ce que tu m'as expliqué voici mon code par rapport a [O] :
Option Explicit
Sub creation_fichiers()
Dim i As Integer
Dim sh, Dlg, plg
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set sh = Sheets(1)
Dlg = sh.Cells(Rows.Count, 1).End(xlUp).Row
Set plg = sh.Range("A5:U" & Dlg)
sh.Range("O6:U" & Dlg).Copy sh.[AA1]
sh.[AA:AB].RemoveDuplicates Columns:=Array(2), Header:=xlYes
sh.[AC1] = sh.[O6]
For i = 2 To sh.Cells(Rows.Count, "AA").End(xlUp).Row
Workbooks.Add
sh.[AC2] = sh.Range("AA" & i)
plg.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=sh.Range("AC1:AC2"), CopyToRange:=ActiveWorkbook.Sheets(1).Range("A1:U1")
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & sh.Range("AB" & i) & "-" & sh.Range("AA" & i) & ".xls", FileFormat:=xlExcel8
ActiveWorkbook.Close False
Next i
sh.[AA:AC].ClearContents
End Sub
Voici l'erreur
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & sh.Range("AB" & i) & "-" & sh.Range("AA" & i) & ".xls", FileFormat:=xlExcel8
Microsoft Office Excel cannot access the file 'c:\User\..\...\...'. There are several possible reasons:
• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook