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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| Sub SautsDePageH()
'par Docmarti 2016/09/12
Dim f As Worksheet
Dim ProchainNumeroPageBreak As Long
Dim Ligne As Long
Dim dern As Long
Dim r As Range
Set f = ThisWorkbook.ActiveSheet
ActiveWindow.View = xlPageBreakPreview
f.ResetAllPageBreaks
ProchainNumeroPageBreak = 1
Ligne = 0
dern = f.Cells(Rows.Count, 1).End(xlUp).Row + 1
Set r = f.Range("A2:A" & dern)
r.RowHeight = 25
While Ligne <= dern
Ligne = Ligne + 1
If f.Cells(Ligne, "H").Value = "SPG" Then
If ProchainNumeroPageBreak > f.HPageBreaks.Count Then
ActiveSheet.HPageBreaks.Add Before:=Rows(Ligne + 1)
Else
Set f.HPageBreaks(ProchainNumeroPageBreak).Location = f.Cells(Ligne + 1, 1)
ProchainNumeroPageBreak = ProchainNumeroPageBreak + 1
End If
End If
If ProchainNumeroPageBreak < f.HPageBreaks.Count Then
If f.HPageBreaks(ProchainNumeroPageBreak).Location.Row < Ligne + 1 Then
ProchainNumeroPageBreak = ProchainNumeroPageBreak + 1
End If
End If
Wend
ActiveWindow.View = xlNormalView
End Sub |
Partager