1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Sub Test1()
Dim feuil As Variant, FL1 As Worksheet
Dim Plage1, Plage2, i As Byte, j As Byte, k As Byte
Application.ScreenUpdating = False
feuil = Array("feuil1", "feuil2")
'Première feuille
Plage1 = Array("$A$1:H30", "$C$32:$G64", "$E$68:$L$85")
'seconde feuille
Plage2 = Array("$B$10:J40", "$A$44:$I74", "$A$78:$L$97")
Tablo = Array(Plage1, Plage2)
'k = 0
For i = 0 To UBound(Plage1) - 1
Set FL1 = Worksheets(feuil(k))
With FL1
For j = 0 To UBound(Plage2)
NoPage = NoPage + 1
'MsgBox "Plage de la page " & NoPage & " : " & Tablo(i)(j) 'juste pour voir
With .PageSetup
.PrintArea = Tablo(i)(j)
.CenterHorizontally = True
.CenterVertically = True
.FitToPagesWide = 1
.FitToPagesTall = 1
.Orientation = xlPortrait ' ou xlLandscape (paysage)
.CenterHeader = "Page " & CStr(NoPage)
End With
.PrintPreview 'juste pour vérifier la validité du code
'.PrintOut 'valider cette ligne pour éditer les pages
Next
End With
Set FL1 = Nothing
k = k + 1
Next
Application.ScreenUpdating = True
End Sub |
Partager