P
PO
Hi,
I have a worksheet with 15 pages of data. ?ActiveSheet.HPageBreaks.Count
returns 14 in the immediate window.
The following code however produces an "Index out of range" error:
Sub FormatDoc()
Dim intI
Dim pb As HPageBreak
Dim rng As Range
For intI = 1 To ActiveSheet.HPageBreaks.Count
Set rng = ActiveSheet.HPageBreaks(intI).Location
ActiveSheet.Range(rng.Address).Resize(1,
10).Borders(xlEdgeTop).Weight = -4138
Next intI
End Sub
The strange thing is that the error occurs for different intI values (i.e.
intI =2 or intI = 5). And sometimes the whole procedure executes without
errors.
There are no inserted pagebreakes in the worksheet only those set by Excel.
Any ideas?
Regards
Pete
I have a worksheet with 15 pages of data. ?ActiveSheet.HPageBreaks.Count
returns 14 in the immediate window.
The following code however produces an "Index out of range" error:
Sub FormatDoc()
Dim intI
Dim pb As HPageBreak
Dim rng As Range
For intI = 1 To ActiveSheet.HPageBreaks.Count
Set rng = ActiveSheet.HPageBreaks(intI).Location
ActiveSheet.Range(rng.Address).Resize(1,
10).Borders(xlEdgeTop).Weight = -4138
Next intI
End Sub
The strange thing is that the error occurs for different intI values (i.e.
intI =2 or intI = 5). And sometimes the whole procedure executes without
errors.
There are no inserted pagebreakes in the worksheet only those set by Excel.
Any ideas?
Regards
Pete