Sub Bouton1_Cliquer()
Dim Cel As Range, WS1 As Worksheet, WS2 As Worksheet, DerLig As Integer, i As Integer
Dim Onglet As Worksheet
Set WS1 = Worksheets("Formations PSST")
Set WS2 = Worksheets("Base habilitation")
DerLig = WS1.Range("A" & Rows.Count).End(xlUp).Row
For i = 4 To DerLig
' si le nom est imprimable et non imprimé
If WS1.Range("AV" & i) = 3 And WS1.Range("AW" & i) <> "I" Then
WS1.Range("AW" & i) = "I" ' ecriture I en col AT
WS2.Range("Y3").Value = WS1.Cells(i, 1).Value
WS2.PageSetup.PrintArea = "A1:Z36"
WS2.Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Imprime_" & i
End If
Next
'Boucle d'impression
For Each Onglet In ThisWorkbook.Worksheets
If InStr(1, Onglet.Name, "Imprime_") > 0 Then
Sheets(Onglet.Name).Select Replace:=False
End If
Next
'Imprime
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=False, IgnorePrintAreas:=True
Fichier = ThisWorkbook.Path & "\Export"
'Sauvegarde
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Fichier & "pdf"
'Nettoyage des onglets
Application.DisplayAlerts = False
For Each Onglet In ThisWorkbook.Worksheets
If InStr(1, Onglet.Name, "Imprime_") > 0 Then ThisWorkbook.Sheets(Onglet.Name).Delete
Next
Application.DisplayAlerts = True
End Sub