Insert Page Break

G

Guest

Is it possible to insert a page break automatically when specific text is
encountered in row A. This report is hundreds of pages long and I need an
automatic page insert macro. Can someone give me the syntax of a macro if
the specific text is "Break"? Thanks for any help.
 
G

Guest

Hi Don
Try
Sub Macropagebreak()
For Each CELL In Range("A:A")
If CELL = "BREAK" Then
CELL.Rows.Select
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
Else
End If
Next
End Sub
 
G

Guest

Thank you for your help. I entered this macro and when I ran it I got the
error message that said - Complie error, variable not defined. The first
instance of the word CELL was highlighted. Please tell me how to define this
variable.
 
D

Dave Peterson

Sub MacroPageBreak()
Dim Cell as Range '<-- add this line
'''rest of code here
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top