Sub Extraction2()
Dim lig%, k%
Dim secteur As String
secteur = Cells(2, 3)
With Feuil3 'ici Feuil1 est sheets("PDF")
.[A4:AS10000].Clear
'Range("A1:AQ3").Copy: .Cells(1, 1).PasteSpecial Paste:=xlPasteFormats
k = 4
For lig = 3 To Range("A1048576").End(3).Row
If Application.CountA(Range("A" & lig & ":F" & lig)) > 0 Then
If Cells(lig, 39) = "A meuler" Or Cells(lig, 43) = "RESTE LA FINITION" Or Cells(lig, 37) = "" Then
Range("A" & lig & ":AQ" & lig).Copy: .Cells(k, 1).PasteSpecial
k = k + 1
End If
End If
Next
Feuil3.Range("A3").AutoFilter Field:=3, Criteria1:=secteur
.Columns("k:AJ").Hidden = True
chemin = "ThisWorkbook.Path & "\Extractions\"
If Dir(chemin, vbDirectory) = ""
Then'MkDir (chemin)
End If
Fichier = "SA à meuler sur" & " " & secteur & " " & "au" & " " & Day(Date) & "-" & Month(Date) & "-" & Year(Date)
On Error Resume Next
Feuil3.ExportAsFixedFormat Type:=xlTypePDF, Filename:=chemin & Fichier & ".pdf"
If Err = 0 Then
MsgBox Fichier & ".Pdf a été créé"
Else
MsgBox "Impossible de créer le fichier PDF", vbExclamation, "ANNULATION"
End If
End With
End Sub