R/T 438 on .HPageBreaks.Add line

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

error: Object doesn't support this prop or method... I don't understand..

Public Sub PrintOnly10() 'Rows set (in page setuup) at top to repeat $4:$4

Dim i As Long
Dim MyRange As Range
Dim MyRange1 As Range
Set MyRange = Range("A5").CurrentRegion 'A5 is first row of data
Set MyRange1 = MyRange.Offset(1, 0).Resize(MyRange.Rows.Count - 1, 9)
With MyRange1
For i = 29 To .Rows.Count Step 10
.HPageBreaks.Add .Cells(i, 1) '<< Getting R/T 438
Next i
End With
End Sub
 
Jim,

Try replacing this line

..HPageBreaks.Add .Cells(i, 1)

with this:

..Parent.HPageBreaks.Add .Cells(i, 1)
 
..Hpagebreaks is used with the worksheet--not the range.

With MyRange1
For i = 29 To .Rows.Count Step 10
.Parent.HPageBreaks.Add .Cells(i, 1) '<< Getting R/T 438
Next i
End With

is one way around it.

.Cells(i, 1).PageBreak = xlPageBreakManual

Is another way.
 
Right on; But why the Parent?


Vergel Adriano said:
Jim,

Try replacing this line

.HPageBreaks.Add .Cells(i, 1)

with this:

.Parent.HPageBreaks.Add .Cells(i, 1)
 
Hi Jim,

Parent because HPageBreaks is a member of the worksheet object, and not the
range. Since you were working with the range object, you needed refer to
it's parent which is the worksheet object.
 
Thanks Vergel !!


Vergel Adriano said:
Hi Jim,

Parent because HPageBreaks is a member of the worksheet object, and not the
range. Since you were working with the range object, you needed refer to
it's parent which is the worksheet object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top