+ Reply to Thread
Results 1 to 4 of 4

VBA macro to paginate worksheet

  1. #1
    Registered User
    Join Date
    10-18-2008
    Location
    New Jersey
    Posts
    12

    VBA macro to paginate worksheet

    I have a worksheet which has names in the first column (starting at A2). My macro sorts on that column. I now need to paginate the worksheet such that there is a page of names for each letter of the alphabet.
    What I am doing now is manually creating the pagebreak with: Worksheets("Sheet1").Rows(20).PageBreak = xlPageBreakManual. Since the row number will change in the future (it is being pulled from an SQL Server), I need to be able to find the row number (in this case 20) each time the name changes its first letter. How to do this?

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA macro to paginate worksheet

    Try this

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  3. #3
    Registered User
    Join Date
    10-18-2008
    Location
    New Jersey
    Posts
    12

    Re: VBA macro to paginate worksheet

    Thanks! That works except it takes over 1 minute to do the pagination. I think it is continuing beyond the last row with a name all the way to Excel's limits. An additional problem is that after the sorted names there are a few dozen rows with no name but with data in other columns and those rows should be on their own page. Think of them as "unnamed" orders. Part of the problem is that I couldn't get a simple copy from a temp column to another column to work with limits.
    I wanted to do something like this:

    Please Login or Register  to view this content.
    but I get an error when I try it so I reverted to copying the whole column with

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: VBA macro to paginate worksheet

    It took less than a second to run on mine. Suggest you upload your sheet.

+ 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. Replies: 3
    Last Post: 05-26-2014, 02:21 AM
  2. [SOLVED] Macro to Copy Master Worksheet create and paste in new auto named worksheet
    By TheRealLethality in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2014, 12:46 AM
  3. Paginate for printing problems??
    By FredMerkle in forum Excel General
    Replies: 2
    Last Post: 08-02-2013, 02:02 PM
  4. [SOLVED] Macro/VBA code to Copy data from primary worksheet to a worksheet opened by macro
    By MHamid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2013, 11:10 AM
  5. Macro to select worksheet based on cell value and then return data to diff worksheet
    By clnossok in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2013, 07:48 PM
  6. Using Spin Button to Vertically Paginate ListBox
    By BeefNoodleSoup in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-16-2012, 09:52 PM
  7. Replies: 0
    Last Post: 05-16-2005, 11:06 AM

Tags for this Thread

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