R
RITCHI
Hi
I want to insert a page break before a cell if the cell value meets
certain conditions.
I've tried the code below which seemd to work some of the time ut not
consistently.
Sub InsertPageBreaks()
Application.ScreenUpdating = False
ActiveSheet.Activate
'ActiveSheet.ResetAllPageBreaks
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 6 Step -1
If InStr(Cells(i, 1).Value, "---") > 0 Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i,
1)
End If
Next
Application.ScreenUpdating = True
End Sub
I want to insert a page break before a cell if the cell value meets
certain conditions.
I've tried the code below which seemd to work some of the time ut not
consistently.
Sub InsertPageBreaks()
Application.ScreenUpdating = False
ActiveSheet.Activate
'ActiveSheet.ResetAllPageBreaks
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 6 Step -1
If InStr(Cells(i, 1).Value, "---") > 0 Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=Cells(i,
1)
End If
Next
Application.ScreenUpdating = True
End Sub