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.
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.
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.
Sincerely,![]()
'This example sets a manual page break to the left of column J on Sheet1. Worksheets("Sheet1").Columns("J").PageBreak = xlPageBreakManual
Leith Ross
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.
I'm thinking it might be because of the PrintArea before. Any thoughts?![]()
ActiveSheet.PageSetup.PrintArea = Range(Cells(5, 2), lastCell).Address ActiveSheet.Columns(6).PageBreak = xlPageBreakManual
Last edited by VBA Noob; 12-03-2008 at 03:05 PM. Reason: Added code tags as per forum rules
Hello Dongman,
I agree with you. Switch them around.
Sincerely,
Leith Ross
Nevermind, got it. Thanks for your help!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks