View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Keith74 Keith74 is offline
external usenet poster
 
Posts: 120
Default Problem finding pagebreaks

Hi

I'm using the following code to find the pagebreaks in a worksheet and
insert a row and some column headings when it finds them. The problem
i'm having is that on the first run through the values returned to the
array containing the row of the pagebreaks are wrong. Once a row has
been inserted everything works fine and the values in the array are
correct. Has anyone come accross this before and can shed a little
light on whats happening?

Thanks

Dim varArray() As Variant
Dim intArrPosition As Integer

With Sheets("Summary")
.Activate
ActiveWorkbook.Names.Add _
"BreakRows", _
"=GET.DOCUMENT(64)"
varArray() = [BreakRows]

ActiveWorkbook.Names("BreakRows").Delete


intArrPosition = 1

If UBound(varArray) < 0 Then
Do Until intArrPosition UBound(varArray)

If intArrPosition <= UBound(varArray) Then
If Len(.Cells(varArray(intArrPosition), "A").Value) < 0
Then
If Cells(varArray(intArrPosition), "A").Value <
"Count:" Then
.Rows(varArray(intArrPosition)).Insert

insert column headings

ActiveWorkbook.Names.Add _
"BreakRows", _
"=GET.DOCUMENT(64)"
varArray() = [BreakRows]

ActiveWorkbook.Names("BreakRows").Delete
End If
End If
End If
intArrPosition = intArrPosition + 1
Loop
End If
End With