PDA

View Full Version : Help Needed with Page Breaks



Poundland
07-07-2008, 09:40 AM
Guys,

I am in need of some advice on adding Page Breaks using VBA into my spreadsheet, I have detailed below a part of my code that is supposed to add the page breaks, the Horizontal Page Break works but the Vertical Page Break adds the break at the designated cell, but it still allows an automatic break to be generated in the middle of my data.

I have tried to format the page setup using the Fittopagewide function but again this does not help.

Can you offer me any advice.

' Inserts a Page Break after each Vendor
ActiveWindow.SelectedSheets.HPageBreaks.Add before:=ActiveCell' Formats Columns
Cells.Select
Selection.Columns.AutoFit
' Sets the Horizontal Page Break
Range("a1").Select
Selection.End(xlToRight).Select
Selection.Offset(0, 1).Select
ActiveWindow.SelectedSheets.VPageBreaks.Add before:=ActiveCell
Range("a1").Select

' Sets the page format for the Far East Template
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "Log Net Far East Shipping Schedule"
.RightHeader = "&D"
.LeftFooter = "&P"
.Orientation = xlLandscape
.Zoom = 80
.FitToPagesWide = 1
.FitToPagesTall = False
End With

Bob Phillips
07-07-2008, 10:46 AM
Have you a workbook we can test it on?

Poundland
07-08-2008, 01:42 AM
Have you a workbook we can test it on?

I have attached the finished book that the Macro creates, this does have the Horizontal Page breaks in as per the VBA codeing, but I had to change the Vertical page breaks manually after the event.