Fergus
Well-known Member
- Joined
- Mar 10, 2004
- Messages
- 1,174
I have a very simple VBA sub which is intended to underline a worksheet at each page break when printed. The total length of the worksheet is 3574 rows. The sub works fine down to row number 1477 but then gives an error message "subscript out of range". I have used this in the past on Excel 2007 and it worked fine over worksheets of up to 600 rows.
Can anyone tell me what I am doing wrong? Here's the sub which I put into Thisworkbook. It is called from a button.
Sub underline()
For Each pgbr In ActiveSheet.HPageBreaks
With pgbr.Location
With Range(.Offset(-1, 0), .Offset(-1, 17)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
Next
End Sub
Can anyone tell me what I am doing wrong? Here's the sub which I put into Thisworkbook. It is called from a button.
Sub underline()
For Each pgbr In ActiveSheet.HPageBreaks
With pgbr.Location
With Range(.Offset(-1, 0), .Offset(-1, 17)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
End With
End With
Next
End Sub