Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I get a runtime error 1004, application or object definition on the line with
the asterisks. While debugging this I noticed that it runs through the 5th iteration of "I" then it stops. This macro does the page setup on each page of long spreadsheets. There is also a routine that does subtotals before it runs through the page break and formatting. So excel might be choking. When it stopped in the watch window the variables a x= 12 RowsPerPage = 99 Row1 = 111 SubTotalRows(I - 1) evaluates to 96 [the line that stops] I noticed one strange thing. If I show the page break preview mode I get the above error. If I run in regular mode then it stops in the same place but I get a runtime error 9 instead and I don't get any values. thanks for any help, ---------------code segment----------- x = ActiveSheet.HPageBreaks.Count With ActiveSheet.HPageBreaks RowsPerPage = .Item(2).Location.Row - .Item(1).Location.Row End With K = 1 PageNumber = 1 Row1 = 0 For I = 0 To UBound(SubTotalRows) Debug.Print I SubTotalRow = SubTotalRows(I) If Row1 = 0 Then Row1 = ActiveSheet.HPageBreaks(PageNumber).Location.Row End If If SubTotalRow Row1 Then ***** Set ActiveSheet.HPageBreaks(PageNumber).Location = Cells(SubTotalRows(I - 1) + 1, 1) ****** Row1 = SubTotalRows(I - 1) + RowsPerPage PageNumber = PageNumber + 1 End If Next I For I = 1 To x If x < ActiveSheet.HPageBreaks.Count Then I = I - (ActiveSheet.HPageBreaks.Count - x) K = I + (ActiveSheet.HPageBreaks.Count - x) x = ActiveSheet.HPageBreaks.Count End If J = ActiveSheet.HPageBreaks(K).Location.Address Row1 = Range(J).Row Set ActiveSheet.HPageBreaks(K).Location = Cells(Row1, 1) K = K + 1 Next I |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error '1004' application or object defined error | Excel Programming | |||
runtime error '1004' application or object defined error. Please help | Excel Programming | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming |