I've written the following code to add a second page to the file when additional rows are needed. After the add, I'm trying to set the page break so that it breaks in the proper location. I've tried several different pieces of code, none seem to work.
The following isn't giving me any error msg, yet the stubborn page break remains before row 65, rather than before row 62 where I want it.
Any help on why this isn't working would be appreciated.
Sub AddPage()
'
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Application.Goto Reference:="BlankPage"
Application.CutCopyMode = False
Selection.Copy
Range("A62").Select
ActiveSheet.Paste
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$118"
With ActiveSheet.PageSetup
.PrintTitleRows = "$11:$14"
End With
ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$118"
With ActiveSheet.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 2
End With
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.HPageBreaks.Add Before:=Rows(62)
ActiveWindow.View = xlNormalView
ActiveSheet.Shapes.Range(Array("Button 17")).Select
Selection.OnAction = "RemovePage"
Selection.Characters.Text = "Remove Page 2"
Range("A14:A15").Select
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub
Bookmarks