December 5, 2016
Sub RepeatRowsExceptLastPage()
Dim xPages As Long, I As Integer, xRg As Range
On Error Resume Next
xPages = ActiveSheet.PageSetup.Pages.Count
Set xRg = Rows("18:19") ' that the rows I want to repeat in each page but not the last page
If xRg Is Nothing Then Exit Sub
On Error Resume Next
If xPages > 0 Then
With ActiveSheet.PageSetup
.PrintTitleRows = xRg.AddressLocal
ActiveSheet.PrintOut from:=0, To:=xPages - 1
.PrintTitleRows = ""
ActiveSheet.PrintOut from:=xPages
End With
End If
End Sub
The above VB does work but split the output files into two files, don't know why? Pls help to debug
1 Guest(s)