I have a Macro that was supplied to me earlier in 2018 from this group, and it will not work any more.
I get the following error.
Run Time Error 1004 Application-Defined or Object-Defined Error.
Sub insertpagebreaks()
' this macro adds page breaks if data in column A changes for printing out new page for each time there is a change.
Dim I As Long, J As Long
J = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For I = J To 2 Step -1
If Range("A" & I).Value <> Range("A" & I - 1).Value Then
ActiveSheet.HPageBreaks.Add Before:=Range("A" & I) '<----- This is the line of code that shows the error in Debug
End If
Next I
End Sub
THANK YOU
I get the following error.
Run Time Error 1004 Application-Defined or Object-Defined Error.
Sub insertpagebreaks()
' this macro adds page breaks if data in column A changes for printing out new page for each time there is a change.
Dim I As Long, J As Long
J = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For I = J To 2 Step -1
If Range("A" & I).Value <> Range("A" & I - 1).Value Then
ActiveSheet.HPageBreaks.Add Before:=Range("A" & I) '<----- This is the line of code that shows the error in Debug
End If
Next I
End Sub
THANK YOU