Variable Page Break
Hi Chris,
Am Thu, 8 Oct 2015 17:42:35 -0700 (PDT) schrieb Christopher Jack:
Thank you for your help. This works until it gets to the next year. Then January is less then December, and doesn't work until February. The page break ends up being a few rows down and dotted when viewed in page break view.
you don't need another IF. Change
If Month(rngC) Month(rngC.Offset(-1, 0)) Then
to
If Month(rngC) < Month(rngC.Offset(-1, 0)) Then:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) < "O1" Then Exit Sub
Dim rngC As Range
With ActiveSheet
With .PageSetup
.PrintArea = "A1:K368"
.Orientation = xlPortrait
End With
.ResetAllPageBreaks
For Each rngC In .Range("A3:A368")
If Month(rngC) < Month(rngC.Offset(-1, 0)) Then
.HPageBreaks.Add rngC
End If
Next
End With
End Sub
Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
|