Computer Learning Zone CLZ Access Excel Word Windows

To teach is to learn twice over

-Joseph Joubert
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Excel Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Page 1 5
Bruno Segers 
    
5 years ago
Hey guys,

Is there a formula or VBA code in Excel that can indicate in a cell how many pages of the so many pages in a specific sheet consists of?
Don't give me any comment to put it in de footer of header please. That i now how to do it.
Bruno from Belgium.
Bruno Segers OP  @Reply  
    
5 years ago
This code does show the correct number of pages, but when printing, it stops its function on the following pages. Is there anyone who can help me further? I have attached the print preview and file.

Option Explicit

Sub Pagenumber()
    Dim xVPC As Integer
    Dim xHPC As Integer
    Dim xVPB As VPageBreak
    Dim xHPB As HPageBreak
    Dim xNumPage As Integer
    xHPC = 1
    xVPC = 1
    If ActiveSheet.PageSetup.Order = xlDownThenOver Then
        xHPC = ActiveSheet.HPageBreaks.Count + 1
    Else
        xVPC = ActiveSheet.VPageBreaks.Count + 1
    End If
    xNumPage = 1
    For Each xVPB In ActiveSheet.VPageBreaks
        If xVPB.Location.Column > ActiveCell.Column Then Exit For
        xNumPage = xNumPage + xHPC
    Next
    For Each xHPB In ActiveSheet.HPageBreaks
        If xHPB.Location.Row > ActiveCell.Row Then Exit For
        xNumPage = xNumPage + xVPC
    Next
    ActiveCell = "REV 1 - Strona " & xNumPage & " - " & Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
End Sub
Richard Rost  @Reply  
          
5 years ago
Hi Bruno. It's been a while since I've done anything like this with Excel VBA (Access is my forte). However, if memory serves you can calculate the number of printed pages in a Worksheet with:

Worksheets(i).PageSetup.Pages.Count

Also, please review the Forum Rules. I don't allow the posting of external links.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Excel Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 6:29:02 PM. PLT: 1s