ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Inserting automatic page breaks (https://www.excelbanter.com/excel-discussion-misc-queries/263663-inserting-automatic-page-breaks.html)

LStewart

Inserting automatic page breaks
 
Have a list of books checked out to students. Need a page break at each
change in name.

Gord Dibben

Inserting automatic page breaks
 
Assuming names are in column A. Adjust to suit.

Sub InsertBreak_At_Change()
'Sandy Mann July 1st, 2007
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For X = LastRow To 2 Step -1
If Cells(X, 1).Value < Cells(X - 1, 1).Value Then
If Cells(X, 1).Value < "" Then
If Cells(X - 1, 1).Value < "" Then
Cells(X, 1).PageBreak = xlPageBreakManual
End If
End If
End If
Next X
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 12 May 2010 16:15:01 -0700, LStewart
wrote:

Have a list of books checked out to students. Need a page break at each
change in name.



LStewart

Inserting automatic page breaks
 


"Gord Dibben" wrote:

Assuming names are in column A. Adjust to suit.

Sub InsertBreak_At_Change()
'Sandy Mann July 1st, 2007
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For X = LastRow To 2 Step -1
If Cells(X, 1).Value < Cells(X - 1, 1).Value Then
If Cells(X, 1).Value < "" Then
If Cells(X - 1, 1).Value < "" Then
Cells(X, 1).PageBreak = xlPageBreakManual
End If
End If
End If
Next X
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 12 May 2010 16:15:01 -0700, LStewart
wrote:

Have a list of books checked out to students. Need a page break at each
change in name.


.
This worked wonderfully!! Thank you so much!


Gord Dibben

Inserting automatic page breaks
 
Good to hear

Thanks for the feedback

On Fri, 14 May 2010 15:01:01 -0700, LStewart
wrote:



"Gord Dibben" wrote:

Assuming names are in column A. Adjust to suit.

Sub InsertBreak_At_Change()
'Sandy Mann July 1st, 2007
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For X = LastRow To 2 Step -1
If Cells(X, 1).Value < Cells(X - 1, 1).Value Then
If Cells(X, 1).Value < "" Then
If Cells(X - 1, 1).Value < "" Then
Cells(X, 1).PageBreak = xlPageBreakManual
End If
End If
End If
Next X
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP

On Wed, 12 May 2010 16:15:01 -0700, LStewart
wrote:

Have a list of books checked out to students. Need a page break at each
change in name.


.
This worked wonderfully!! Thank you so much!




All times are GMT +1. The time now is 02:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com