+ Reply to Thread
Results 1 to 6 of 6

Count the number of pages (except pages with no data)

  1. #1
    Spammer
    Join Date
    06-29-2020
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    95

    Count the number of pages (except pages with no data)

    excel file, Sheet1 has 17 pages in total. Except for page 3, the remaining pages have data. How do I use the vba code to find the result of the page number containing 16 pages of data. Thank you all. Wish one good day
    Attached Files Attached Files

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Count the number of pages (except pages with no data)

    Maybe :
    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Count the number of pages (except pages with no data)

    Amazing my friend. You are a legend
    I just use CountA instead of Count
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Count the number of pages (except pages with no data)

    No, in fact, you are the legend Yasser, the correct way is using counta as your suggestion.

    @minhys1 : please change using counta, as suggested by Yasser.

  5. #5
    Spammer
    Join Date
    06-29-2020
    Location
    Vietnam
    MS-Off Ver
    2013
    Posts
    95

    Re: Count the number of pages (except pages with no data)

    karedog, YasserKhalil. You both are so excellent. The results are exactly as I wanted. Thank you very much
    Do not know, is it possible to expand in other cases as well:
    * Case 2: the total number of pages without data of all the sheets in the open excel file
    * Case 3: The total number of sheets without data of the specified sheet in the open excel file is entered by the user (any sheet or more than 2 sheets).
    * Case 4: the total number of pages without data of all sheets (or Sheet specified by the user) in the excel file is not open, need to indicate the path and file name to be specifically checked.
    * Case 5: I can't think of anything else next

  6. #6
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Count the number of pages (except pages with no data)

    You are welcome and thanks for the rep.point.

    The core of my code is the "Function GetPageArea(sht As Worksheet)", we put a sheet as its parameter, and the function will return an array of page ranges divided by horizontal break. Then using counta for each range in this array we can determine if the current page is empty or not.

    So for your other cases, you just call this function several times, and then totaling all the results.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count number of pages of pdf files in directory by VBA
    By Jesseke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2020, 04:41 AM
  2. Macro help with pages and pages of data!
    By svinet in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2014, 08:16 PM
  3. [SOLVED] count the number of pages of a pdf file
    By krazyhype19 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-18-2014, 12:16 AM
  4. Macro to count rows and determine number of print pages
    By becca5301 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2012, 05:32 PM
  5. Count number of pages
    By rm81 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-09-2006, 12:55 PM
  6. How to count number of pages in a named range
    By rm81 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2006, 12:55 PM
  7. Replies: 0
    Last Post: 02-15-2006, 08:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1