+ Reply to Thread
Results 1 to 5 of 5

Setting Page Breaks

Hybrid View

  1. #1
    Registered User
    Join Date
    11-24-2008
    Location
    Atlanta
    Posts
    11

    Setting Page Breaks

    Does anyone know how to write code to set page breaks every 4th column, or in certain intervals. For rows I have a simple .FitToPagesTall = 1, but I'm looking for something more dynamic for the columns. Thanks in advance.
    Last edited by VBA Noob; 12-03-2008 at 06:27 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,259
    Hello dongman,

    Here is an example. Column breaks are set to the left of the column specified. You could you a For...Next loop to set multiple column breaks by setting the Step value to 4 to set a page break every 4 columns.
      'This example sets a manual page break to the left of column J on Sheet1.
       Worksheets("Sheet1").Columns("J").PageBreak = xlPageBreakManual
    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    11-24-2008
    Location
    Atlanta
    Posts
    11
    Thanks Leith, I'm still having some trouble though. When I put in the code, it runs but doesn't give me the page break. Perhaps you could look at what I have thus far.


    ActiveSheet.PageSetup.PrintArea = Range(Cells(5, 2), lastCell).Address
    ActiveSheet.Columns(6).PageBreak = xlPageBreakManual
    I'm thinking it might be because of the PrintArea before. Any thoughts?
    Last edited by VBA Noob; 12-03-2008 at 03:05 PM. Reason: Added code tags as per forum rules

  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,259
    Hello Dongman,

    I agree with you. Switch them around.

    Sincerely,
    Leith Ross

  5. #5
    Registered User
    Join Date
    11-24-2008
    Location
    Atlanta
    Posts
    11
    Nevermind, got it. Thanks for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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