Option Explicit
Public ZonePrint As Range 'Définit la zone d'impression
Sub Imprimer()
Application.ScreenUpdating = False
With Sheets("Data").PageSetup
.PrintTitleRows = Sheets("Data").Rows("2").Address
.CenterHeader = "Liste des employés pour Alain"
.LeftFooter = "&T"
.CenterFooter = Format("&D", "yyyy-mm-dd")
.RightFooter = "Page &P sur &N"
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape 'Portrait ou Landscape
.Draft = False
.PaperSize = xlPaperLegal 'xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
End With
With Sheets("Data")
.Select
Dim Fin, Cel
Fin = Sheets("Data").Range("A65535").End(xlUp).Row
Set ZonePrint = Range("A2:P" & Fin)
'Masquer la colonne du nom du directeur
Sheets("Data").Columns("D").EntireColumn.Hidden = True
'Masquer les lignes dont le nom du directeur est autre que Alain
For Each Cel In ZonePrint.Range("D2:D" & Fin)
If Not Cel.Value = "Alain" Then Cel.EntireRow.Hidden = True
Next
ZonePrint.ExportAsFixedFormat Type:=xlTypePDF, Filename:="ListeEmployésPourAlain", Quality:=xlQualityStandard, _
IncludeDocProperties:=False, IgnorePrintAreas:=True, OpenAfterPublish:=True
Sheets("Data").Cells.EntireColumn.Hidden = False
Sheets("Data").Cells.EntireRow.Hidden = False
End With
Application.ScreenUpdating = True
End Sub