A macro to exclude the page Header from the last page in the Excel report.
Because this can be helpful when we want to include a summary page in the report but the Header should appear in each page but not the last page of the report.
Hi David,
Can you put the summary page at the start? You can have a different header for the first page.
Phil
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
David,
Can't debug it without your workbook.
Regards
Phil
Thanks Philip, I manage to resolve it. so pls close this case.