fallinup00
New Member
- Joined
- Jan 16, 2013
- Messages
- 8
Hi,
I am trying to modify the code below to add horiz. page breaks before each instance of the word "Employer" in column A. The code, as it is below, works perfectly, but it places the page break after the row rather than before it.
If I change the line from:
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(1) 'adds break after
to:
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(0)
or
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c
I receive errors when running the marco.
Any ideas?
Cheers,
-A
Original Code:
Dim c As Range
Dim FirstAddress As String
Set c = Columns("A").Find(What:="Employer", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(1)
Set c = Columns("A").FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
I am trying to modify the code below to add horiz. page breaks before each instance of the word "Employer" in column A. The code, as it is below, works perfectly, but it places the page break after the row rather than before it.
If I change the line from:
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(1) 'adds break after
to:
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(0)
or
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c
I receive errors when running the marco.
Any ideas?
Cheers,
-A
Original Code:
Dim c As Range
Dim FirstAddress As String
Set c = Columns("A").Find(What:="Employer", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=c.Offset(1)
Set c = Columns("A").FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If