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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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