View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Counting pages for tab

Based on the code shown he 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

"Art Vandelay" wrote:

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.