1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub SetPrint()
Dim MaRech As Range
With ActiveSheet.Range(Cells(2, 6), Cells(Columns(1).Cells.Count, 6)) 'Défini la plage de recherche hors ligne 1
Set MaRech = .Find("PAGE", LookIn:=xlValues, lookat:=xlPart) 'Trouve le mot PAGE (pour déterminer début et fin de page)
If Not MaRech Is Nothing Then
firstAddress = MaRech.Address 'Permet de pas boucler sans fin
Do
If Application.Count(ActiveSheet.Range(Cells((MaRech.Row) - 58, 6), Cells(MaRech.Row, 6))) > 1 Then 'Vérifie si il y des données pour la page en cours
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$" & MaRech.Row - 1 'Défini la plage d'impression
Else
Exit Sub 'Sors de la procédure si rien sur la page en question
End If
Set MaRech = .FindNext(MaRech) 'Passe au mot Page suivant
Loop While Not MaRech Is Nothing And MaRech.Address <> firstAddress 'Permet la boucle
End If
End With
End Sub |