L
Laurence Lombard
I want to print a sheet columns A:N (rows vary) 1 page wide with pagebreaks
at certain rows (91+n*90) eg 91,181,271 etc but am having trouble with old
manual pagebreaks and the automatic pagebreaks.
The code below (modified from earlier advice on this newsgroup) results in
pagebreaks above 90,91,178,181,268 and 271 with BottomRow = 328.
How do control PageSetup to be one page wide with breaks at 91,181,271?
Thanks
Laurence
*******************************************************
Sub SetPageBreaks()
Dim hpb As HPageBreak
Sheets("Stuk P").Activate
BottomRow = Range("A2000").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = Range("A1", "N" & BottomRow).Address
ActiveSheet.PageSetup.Zoom = False
ActiveSheet.PageSetup.FitToPagesWide = 1
ActiveSheet.PageSetup.FitToPagesTall = False
For Each hpb In ActiveSheet.HPageBreaks
If hpb.Type = xlPageBreakManual Then hpb.Delete
Next hpb
Breakline = 91
Do While Breakline < BottomRow
ActiveSheet.HPageBreaks.Add ActiveSheet.Range("A" & Breakline)
Breakline = Breakline + 90
Loop
End Sub
at certain rows (91+n*90) eg 91,181,271 etc but am having trouble with old
manual pagebreaks and the automatic pagebreaks.
The code below (modified from earlier advice on this newsgroup) results in
pagebreaks above 90,91,178,181,268 and 271 with BottomRow = 328.
How do control PageSetup to be one page wide with breaks at 91,181,271?
Thanks
Laurence
*******************************************************
Sub SetPageBreaks()
Dim hpb As HPageBreak
Sheets("Stuk P").Activate
BottomRow = Range("A2000").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = Range("A1", "N" & BottomRow).Address
ActiveSheet.PageSetup.Zoom = False
ActiveSheet.PageSetup.FitToPagesWide = 1
ActiveSheet.PageSetup.FitToPagesTall = False
For Each hpb In ActiveSheet.HPageBreaks
If hpb.Type = xlPageBreakManual Then hpb.Delete
Next hpb
Breakline = 91
Do While Breakline < BottomRow
ActiveSheet.HPageBreaks.Add ActiveSheet.Range("A" & Breakline)
Breakline = Breakline + 90
Loop
End Sub