I want to automatically set my page break preview.
I tried
Worksheets("Stack").Range("A2:M33").PageBreak = xlPageBreakManual
I get
Unable to set Pagebreak Property of the range Class
I know it's almost two years late, but just not to leave this unanswered. I did the following:
Dim WSh As Worksheet, Rng1 As Range, Rng2 As Range
Set WSh = Sheets("Stack")
    Set Rng1 = Range("A5")
    Set Rng2 = Range("N34")
WSh.ResetAllPageBreaks
    'From
    If Rng1.Row <> 1 Then WSh.HPageBreaks.Add before:=Rng1
    If Rng1.Column <> 1 Then WSh.VPageBreaks.Add before:=Rng2
    'To
    WSh.HPageBreaks.Add before:=Rng2
    WSh.VPageBreaks.Add before:=Rng2
That worked. You would just need to ensure some handling when you manage column "A" or row "1", but that can be easily sorted out with a couple Ifs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With