I'm trying to split up a sheet using page breaks:
Sub PageBreaker()
Dim rFound As Range
Set rFound = Cells.Find("Marker", LookIn:=xlValues)
If Not rFound Is Nothing Then
firstAddress = rFound.Address
Do
With rFound.EntireRow
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=rFound.Offset(3, 0)
End With
Set rFound = Cells.FindNext(rFound)
Loop While Not rFound Is Nothing And rFound.Address <> firstAddress
End If
End Sub
and that's working fine !
But when I add the following code in the innermost with statement to create a row where I can add column headers the whole thing goes into a continuous loop :
rFound.EntireRow.Insert
If I get this working how do I add the same text in the header rows. Something like this?? But how do I work it for each newly inserted row??
Range("B*").Select
ActiveCell.FormulaR1C1 = "Column B"
I don't know how to get the cell references right.
Please Help !!!!!!!!
Sub PageBreaker()
Dim rFound As Range
Set rFound = Cells.Find("Marker", LookIn:=xlValues)
If Not rFound Is Nothing Then
firstAddress = rFound.Address
Do
With rFound.EntireRow
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=rFound.Offset(3, 0)
End With
Set rFound = Cells.FindNext(rFound)
Loop While Not rFound Is Nothing And rFound.Address <> firstAddress
End If
End Sub
and that's working fine !
But when I add the following code in the innermost with statement to create a row where I can add column headers the whole thing goes into a continuous loop :
rFound.EntireRow.Insert
If I get this working how do I add the same text in the header rows. Something like this?? But how do I work it for each newly inserted row??
Range("B*").Select
ActiveCell.FormulaR1C1 = "Column B"
I don't know how to get the cell references right.
Please Help !!!!!!!!