Merci à Roblochon et au tout Puissant job75
Une sauce de vos deux solutions donne ceci et c'est du bon:
Dim T1, T2, T3, T4, X As String, p, p1 As Range, dl As Integer
dl = Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
If dl = 1 Then MsgBox " Aucun Patient Enregistr? ", 48: Exit Sub
If MsgBox(" Voulez_Vous Imprimer la Grille ? ", vbYesNo + 32) = vbYes Then
X = InputBox("Saisir le Trimestre Souhait?: T1,T2,T3,T4 ", "Impression")
If X = "" Then MsgBox "Aucun Trimestre determin? Veuillez reesayer ", 64: Exit Sub
If InStr(1, "T1;T2;T3;T4", UCase(X)) > 0 Then
If Application.Dialogs(Excel.XlBuiltInDialog.xlDialogPrinterSetup).Show = False Then Exit Sub
ActiveSheet.Unprotect "2580"
Set p = [A1].CurrentRegion.Resize(dl, 8)
Set p1 = [A1].CurrentRegion.Resize(dl, 7)
With ActiveSheet.PageSetup
.PrintArea = p.Address
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.CenterHorizontally = True
.CenterVertically = False
.CenterHeader = "Grille de Dispensation ARV " & X
End With
p.AutoFilter 8, X
p1.PrintOut Copies:=1, Collate:=True
p.AutoFilter
ActiveSheet.Protect "2580"
End If
End If
Application.ScreenUpdating = True