My table has the categories all in column A, starting with "A3". The following columns have the data and the number of columns may vary each time the report is run. Row 1 has the chart title and row 2 has a legend ("A1:G2"). "H1" to end is blank. Since the data is dynamic the number of pages also varies. I'd like to have the title & legend on the top of each page.
If I list the rows in page setup, the entire row is selected. The information I need repeated is only in ("A1:G2"). I can't code to copy and paste "A1:G2" because I never know how many pages I'll have. The workbook title is listed as the header on all pages.
Public Sub testsub()
Dim ws As Worksheet
Dim surf As Worksheet
With surf.PageSetup
.PrintTitleRows = "$1:$2"
.PrintTitleColumns = "$A:$A"
End With
Application.PrintCommunication = True
surf.PageSetup.PrintArea = ""
With surf.PageSetup
.LeftHeader = ""
.CenterHeader = "Test Workbook"
.RightHeader = ""
.LeftFooter = "&D"
.CenterFooter = "&G"
.RightFooter = "&P"
.CenterHorizontally = True
.CenterVertically = True
End With
Application.PrintCommunication = True
End Sub
I'd like "A1:G2" on each page of the worksheet. Thank you!