Using Excel, I'd like to show the page number on the first sheet, where the start other sheets can be found.

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
So you want the number of the first row of each page where?
Your request "on the first sheet that is part of the larger PDF" does not mean anything.
"In Column a starting at the first row" means something as does "in Range("A45") and subsequent each cell to the right."
 
Upvote 0
So you want the number of the first row of each page where?
Your request "on the first sheet that is part of the larger PDF" does not mean anything.
"In Column a starting at the first row" means something as does "in Range("A45") and subsequent each cell to the right."
No, "the page number where each sheet will start in the PDF".

If you only read that part but there is more than that there. ???
"I'd like to get the page number" ← This would be a page number. A page number like page 13 of 38 pages.
"where each sheet will start in the PDF" ← This would be where each sheet starts. The PDF has 38 pages, where is the first page that each sheet starts on? The first sheet in the PDF starts on page 1 and then the next sheet starts on what page?
"and include it on the first sheet that is part of the larger PDF." ← This is the first sheet, that would be the first one in the larger PDF.

Yes, those all mean something but are not relevant.

Is there a way to find the number of pages that a sheet will have? Like in the linked example from MS but that will work or can be made to work.
 
Upvote 0
Code:
MsgBox ActiveSheet.PageSetup.Pages.Count

This should show the pages in the print area
 
Upvote 0
Code:
MsgBox ActiveSheet.PageSetup.Pages.Count

This should show the pages in the print area
This seems to work, even when rows are filtered out but sometimes it's not updating. I can run the report and it will so the same number of pages.

If I change the value manually in the cell to something else then it updates to the new value. ???
 
Upvote 0
Do you save the file after making changes? If not, you should.
Put the Page # etc in the footer.
 
Upvote 0
Now I see that it is an update behind but how is that working?

I run the script and the number of pages is 59.

I run it again after hiding some rows but don't print and it is still 59. I change nothing and run it again after a print and then it updates to 30.

Like 'PageSetup' only updated after you print?

Saving each time did not help.
 
Upvote 0
What is the print range set to?
Sorry, not sure what that is or where it is?
Is it the Print Area?
1727827228153.png
 
Upvote 0
If you want to print or save to PDF, you need to let the computer know what to print.
You could have a sheet with 250 rows of data but if you only want to print the first 75 rows, you need to let the computer know.
That would be the print range or range to be printed.



 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,182
Members
452,615
Latest member
bogeys2birdies

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