Counting pages for tab

A

Art Vandelay

G'day All

Would anyone know the macro to count the number of pages each that would
print out for each tab.

For example you had 3 tabs.
First one is the summary page (where the answer to this question goes)
Second one has data in it and prints out 5 pages
Third one has 3 pages.

So the answer would be (assuming starting at A1)
1
5
3

Thanks in advance.
 
J

JLatham

Based on the code shown here: http://www.ozgrid.com/VBA/printed-pages.htm
Modified, we can come up with this macro

Sub HowManyPagesBreaks()
Dim iHpBreaks As Integer, iVBreaks As Integer
Dim iTotPages As Integer

iHpBreaks = ActiveSheet.HPageBreaks.Count + 1
iVBreaks = ActiveSheet.VPageBreaks.Count + 1
iTotPages = iHpBreaks * iVBreaks

Range("A1") = iTotPages
'get 2nd sheet's page count
'change Sheet2 to actual tab name
iHpBreaks = Worksheets("Sheet2").HPageBreaks.Count + 1
iVBreaks = Worksheets("Sheet2").VPageBreaks.Count + 1
Range("A2") = iHpBreaks * iVBreaks
'get 3rd sheet's page count
'change Sheet3 to actual tab name
iHpBreaks = Worksheets("Sheet3").HPageBreaks.Count + 1
iVBreaks = Worksheets("Sheet3").VPageBreaks.Count + 1
Range("A3") = iHpBreaks * iVBreaks
End Sub
 
A

Art Vandelay

Thanks JLatham,

It wasn't what I was exactly after, but it did point me in the right
direction.
So thanks, for without your help I would still be floundering.
If I get the whole thing working I might post it for everyone.
Basically I'm trying to create a Table of Contents with page (not tabs)
numbers that work with a variable number of tabs.
 
A

Art Vandelay

Thanks JLatham,

It wasn't what I was exactly after, but it did point me in the right
direction.
So thanks, for without your help I would still be floundering.
If I get the whole thing working I might post it for everyone.
Basically I'm trying to create a Table of Contents with page (not tabs)
numbers that work with a variable number of tabs.
 
J

JLatham

If you need more help, get in touch directly via email - the system here
hasn't notified me of a response to a post in weeks. Remove spaces:
Help From @ JLatham Site.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top