A
AshMorK
Hi All,
I'm using the following code to insert a hpagebreak everytime a specific
value ("Cuenta") is found. The problem is that although it works perfectly
in a simple test workbook, it returns the '1004' Runtime error (Application
or Objet defined error) when I try to use it in a more complex workbook.
Sub addhpb()
Dim rng As Range
Worksheets(1).ResetAllPageBreaks
For Each rng In ActiveSheet.Range("b1:b82")
If Not rng.Row = 1 Then
If rng.Value = "Cuenta" Then
ActiveSheet.HPageBreaks.Add Before:=Range("b" &
rng.Row).EntireRow.Offset(-2)
End If
End If
Next rng
End Sub
Thanks in Advance!
I'm using the following code to insert a hpagebreak everytime a specific
value ("Cuenta") is found. The problem is that although it works perfectly
in a simple test workbook, it returns the '1004' Runtime error (Application
or Objet defined error) when I try to use it in a more complex workbook.
Sub addhpb()
Dim rng As Range
Worksheets(1).ResetAllPageBreaks
For Each rng In ActiveSheet.Range("b1:b82")
If Not rng.Row = 1 Then
If rng.Value = "Cuenta" Then
ActiveSheet.HPageBreaks.Add Before:=Range("b" &
rng.Row).EntireRow.Offset(-2)
End If
End If
Next rng
End Sub
Thanks in Advance!