Different footer for each page

vlsmithika

New Member
Joined
Oct 23, 2017
Messages
3
Hi,
I have a workbook with a macro which generates 147+ pages. i would like to have first page, last page and rest of the pages different. my footer should give the count of rows printed till the current page. I am also breaking pages such as each page has 35 rows in it. Below is the code i tried. issue is i am not getting different footer for different page. any other code is also welcome. Thank you.

Sheets("Preview").Select
FirstDataRow = 15
RowsPerPage = 35
headrow = FirstDataRow - 1
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
PageCount = (FinalRow - headrow) / RowsPerPage
PageCount = Application.WorksheetFunction.RoundUp(PageCount, 0)
Set xWs = Sheets("Preview")
Set findRow = Sheets("Preview").Range("A:A").Find(What:="VIN", LookIn:=xlValues)
findRowNumber = findRow.Row + 2
xRow = 35
xWs.ResetAllPageBreaks
xLastrow = xWs.Range("A" & Rows.Count).End(xlUp).Row

For i = xRow + findRowNumber To xLastrow Step xRow
xWs.HPageBreaks.Add Before:=xWs.Cells(i, 1)

j = j + 1
TotaltillthisPage = 7 * j

If j = PageCount Then
Totallastpage = (FinalRow - FirstDataRow) / 5
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.CenterFooter = "&""Arial,Bold""&12Total Number of Repairs for Model Year 2017 = " & Format(Totallastpage, "#,##0") & vbNewLine & "Total Number of Repairs to this point= " & Format(TotaltillthisPage, "#,##0") & vbNewLine & " Page: &P of &N"
End With

Exit For

End If

Application.PrintCommunication = False
With ActiveSheet.PageSetup
.CenterFooter = "&""Arial,Bold""&12Total Number of Repairs to this point= " & Format(TotaltillthisPage, "#,##0") & vbNewLine & " Page: &P of &N"
End With

Next i
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,214
Messages
6,170,777
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top