+ Reply to Thread
Results 1 to 4 of 4

Finding page breaks in excel sheets & inserting empty row

  1. #1
    Forum Contributor
    Join Date
    06-02-2005
    Posts
    100

    Finding page breaks in excel sheets & inserting empty row

    Hi all,

    I am trying to find a way to identify which page a cell is on (after a print preview is performed) and then insert rows to the worksheet based on what values are found before and after the page break:

    if values on page1 <> values on page2 then just add header:

    1
    1
    1
    1
    ----page break----
    2
    2
    2
    3
    3

    becomes:

    1
    1
    1
    1
    ----page break----
    <insert row>
    2
    2
    2
    3
    3

    and if values page1 = values page2 then insert rows until they don't

    1
    1
    1
    1
    2
    2
    -------page break-----
    2
    2
    3
    3
    3

    becomes

    1
    1
    1
    1
    <insert row>
    <insert row>
    ----page break----
    <insert row>
    2
    2
    2
    2
    3
    3
    3


    The code I have so far is:

    Please Login or Register  to view this content.
    where the two lines with the #getPageNumber()# variable standin is where I don't know the command for getting the page number.

    Is there an easy way to get this?
    Last edited by Ouka; 04-09-2015 at 08:38 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Finding page breaks in excel sheets & inserting empty row

    Hello Ouka,

    This is not such a simple task. You have do the caluclations yourself. Here is link to site that has a VBA macro to do this.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    06-02-2005
    Posts
    100

    Re: Finding page breaks in excel sheets & inserting empty row

    Hmmm.. Getting all sorts of errors with that code. Will see if I can pick it apart. Thanks for the pointing in a right direction.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Finding page breaks in excel sheets & inserting empty row

    Hello Ouka,

    I have not run that code before. Sorry you're having problems with it. If you get stuck, let me know.

+ 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. [SOLVED] Inserting & Removing Page Breaks
    By moosetales in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-12-2014, 02:06 PM
  2. Removing Existing Page Breaks and Inserting a Page Break every third Total Line
    By Kalvas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-17-2013, 05:12 AM
  3. Batch Inserting Row Sheets in between page breaks
    By TeraFractal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2008, 06:40 PM
  4. Inserting Page Breaks
    By chrisnelsonusa1 in forum Excel General
    Replies: 3
    Last Post: 12-09-2005, 05:40 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