berlinhammer
Board Regular
- Joined
- Jan 30, 2009
- Messages
- 187
Hello
I am having a very irritating runtime error that I can't understand the cause of. I'm trying to macro a dynamic print area and in the process delete a vertical pagebreak I don't want, the code keeps tripping on an error 1004 application defined/object defined and I can't understand why. Does anyone have any ideas based on the codes below? I've tried all three and none seem to work.
Many thanks
Jon
I am having a very irritating runtime error that I can't understand the cause of. I'm trying to macro a dynamic print area and in the process delete a vertical pagebreak I don't want, the code keeps tripping on an error 1004 application defined/object defined and I can't understand why. Does anyone have any ideas based on the codes below? I've tried all three and none seem to work.
Many thanks
Jon
Code:
Sub PrintEntity()
Dim output As Range
Dim sh As Worksheet
Dim vpbL As VPageBreak
Set sh = ThisWorkbook.Sheets("P&L Summary")
Set output = sh.Range("rngOutput").CurrentRegion
Set vpbL = sh.VPageBreaks(1)
sh.Range("rngFilter").AutoFilter Field:=1, Criteria1:="TRUE"
sh.ResetAllPageBreaks
sh.PageSetup.PrintArea = output.Address
vpbL.Delete
End Sub
Code:
Sub x()
With ActiveSheet
If .VPageBreaks.Count > 0 Then
.VPageBreaks(1).Delete
End If
End With
End Sub
Code:
Sub y()
ActiveSheet.VPageBreaks(1).Delete
End Sub
Last edited: