+ Reply to Thread
Results 1 to 11 of 11

Excel 365 VBA command to return the current page number of a sheet

  1. #1
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Excel 365 VBA command to return the current page number of a sheet

    Hi
    is there an Excel 365 VBA command to return the current page number of a sheet?
    Regards

  2. #2
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,361

    Re: Excel 365 VBA command to return the current page number of a sheet

    Do you mean the page of a selection in a print area or the index number of a worksheet?

    Index number of a worksheet:
    Please Login or Register  to view this content.
    If things don't change they stay the same

  3. #3
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Re: Excel 365 VBA command to return the current page number of a sheet

    Assume I have a sheet with three pages. I want to display the sentence "Page 1 of 3" in the first page, "Page 2 of 3" in the second page, "Page 3 of 3 " in the third page. I do not want to use footer. I can count the total pages but how to assign the individual pages.

  4. #4
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Re: Excel 365 VBA command to return the current page number of a sheet

    Assume I have a sheet with three pages. I want to display the sentence "Page 1 of 3" on the first page, "Page 2 of 3" on the second page, and "Page 3 of 3 " on the third page. I do not want to use the footer. I can count the total pages but how do assign the individual pages.

  5. #5
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,361

    Re: Excel 365 VBA command to return the current page number of a sheet

    So you actually want a value on the sheet at the top of each page?

    Is the range fixed, i.e. does each page have a set count of rows?
    Has the range been set as a print area?

    The Footer is the easiest way but it only shows when you print, I am guessing that is not what you are after:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Re: Excel 365 VBA command to return the current page number of a sheet

    Yes, I want the value on the sheet put in cell (G7)
    yes each page consists from 50 rows
    yes, has the same print area (A3).

  7. #7
    Forum Expert CheeseSandwich's Avatar
    Join Date
    12-22-2021
    Location
    Kent, England
    MS-Off Ver
    365 - 2404-17531.20128
    Posts
    1,361

    Re: Excel 365 VBA command to return the current page number of a sheet

    I am not sure what 'print area (A3)' means.

    I assume that if the value is to start at G7 then it is more of a header than a footer.

    If you have a print range set on the sheet then the below will add page numbers as a header to each page that consists of 50 rows.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Re: Excel 365 VBA command to return the current page number of a sheet

    A3 paper size
    there is more header, I set rows(1-11) to print as a title for each page. The "page # of #" is included within rows (1-11).
    I will try this code.
    shall the result of this code stored in the cell, for example, "G7"?

  9. #9
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Re: Excel 365 VBA command to return the current page number of a sheet

    if some rows are hidden by code, does this code work perfectly?

  10. #10
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,234

    Re: Excel 365 VBA command to return the current page number of a sheet

    Below is the initial concept of the macro when the rows can have different heights. The macro requires defining the print area manually or by code in advance. The numbering will be inserted in the top right cell of each page.
    Please Login or Register  to view this content.
    Artik

  11. #11
    Forum Contributor
    Join Date
    07-08-2022
    Location
    Baghdad
    MS-Off Ver
    365
    Posts
    145

    Re: Excel 365 VBA command to return the current page number of a sheet

    Thx. for your reply
    Can I send the file to you? I am a beginner in VBA and properly I will make many mistakes.
    @Artik

+ 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. [vba] get current page number of ....pages
    By minhys1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2020, 09:01 PM
  2. [SOLVED] Return to top page command button
    By RJ1969 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2019, 02:54 PM
  3. return back to current page after routine
    By jackf-nc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2016, 09:06 PM
  4. Replies: 6
    Last Post: 11-17-2013, 01:40 PM
  5. [SOLVED] Excel 2002 VBA code to return a page number within a worksheet
    By JCIrish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-19-2006, 05:30 PM
  6. [SOLVED] How to display current page number in any cell of that page.
    By Laljeet in forum Excel General
    Replies: 4
    Last Post: 01-25-2006, 03:55 PM
  7. Return number of current sheet
    By Brandon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-26-2005, 01:06 AM

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