Non-sequential Page Number total in Excel Footer?

infinity306

New Member
Joined
Jul 25, 2019
Messages
1
Hi, I would like to know if there is a way to have Page # of # on the footer for each tab when printing? currently we have Page &[Page] of &[Pages] in the custom footer, but unless we print or export each tab individually to PDF it ends up with Page 1 of {total number of pages in workbook} Would like it to just have the number of pages per sheet/tab, but don't see any code to do such.. yes we can set a starting page number for 1 instead of auto, but that doesn't help for the ending page number on each tab. and there workbooks can have over 20 tabs. any solution you can see to this? Even using VBA would be ok. I don't understand why Microsoft hasn't apparently added a code to do this in all this time. seem simple enough?

Thanks for any help.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi
Welcome to the board

I also don't know of a code to get the number of pages of each worksheet.

What I'd do is to build my own footer for each worksheet, getting the page count of each worksheet from the PageSetup object.

Before printing: Insert the code below in a general module and execute it. This builds a footer for each sheet.

Then select some sheets and print them.


Code:
Sub SetFirstLastPageWS()
Dim ws As Worksheet
    
For Each ws In ActiveWorkbook.Sheets
    With ws.PageSetup
        If .Pages.Count > 0 Then
                .FirstPageNumber = 1
                .RightFooter = "&P " & ws.PageSetup.Pages.Count
        End If
    End With
Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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