Changing Page Numbers

karenbluez

New Member
Joined
Apr 29, 2009
Messages
18
I have spreadsheet with various sheets that print as a book.
So sheet1 will be the Cover, sheet2 the Index, sheet3 the first report, etc.
Each sheet is not 1 page. The page numbers have to follow on each other.
So I've found a macro to calculate how many pages there are per sheet.

Code:
        'i is the row numbers where the sheet names are stored.

        For i = 45 To 64
        MySheet = Worksheets("Settings").Cells(i, 3).Value
        Worksheets(MySheet).Activate
        ActiveWindow.View = xlPageBreakPreview

        Worksheets(MySheet).DisplayAutomaticPageBreaks = True
        HorizBreaks = Worksheets(MySheet).HPageBreaks.Count
        HPages = HorizBreaks + 1
        VertBreaks = Worksheets(MySheet).VPageBreaks.Count
        VPages = VertBreaks + 1
        NumPages = HPages * VPages
        Worksheets(MySheet).DisplayAutomaticPageBreaks = False

        Worksheets("Settings").Cells(i, 4) = NumPages
        
    Next i
This code then insert the number of pages on the Settings sheet, where I can calculate the first page number of each sheet, example Sheet4 is page number 12.

I want to know if there is a way to read from the Settings sheet these numbers and insert them in this Print dialogue box per sheet... in the First Page Number block which is currently on Auto.



Uploaded with ImageShack.us
moz-screenshot.png


I need the correct page numbers to show, so if I only print out Report 2 which starts on page 5 and is 5 pages long, Page 5 needs to be at the bottom of the first page of Report 2 and Page 10 on the last page of Report 2.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You simply do a page setup in your code, like:
ActiveSheet.PageSetup.FirstPageNumber = 6
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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