Microsoft KB Archive/284916

= Excel limits the number of manual page breaks to 1026 =

Article ID: 284916

Article Last Modified on 5/11/2007

-

APPLIES TO


 * Microsoft Office Excel 2007
 * Microsoft Office Excel 2003
 * Microsoft Excel 2002 Standard Edition
 * Microsoft Excel 2000 Standard Edition
 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q284916



SUMMARY
Microsoft Office Excel has a limit of 1026 manual horizontal page breaks for a worksheet. If you run a macro that attempts to exceed this limit, you may receive the following run-time error message:

Not Enough Memory.

Then, you may receive the following error message:

Run-time error '1004':

Application-defined or object-defined error

With Microsoft Excel 2002, you receive the following error message:

Run-time error '1004':

This action exceeds the number of page breaks you can manually add to a worksheet. A worksheet can contain up to 1026 horizontal page breaks.



MORE INFORMATION
The following Excel Visual Basic for Applications (VBA) macro illustrates how the error might occur. Sub Test Dim oSheet As Worksheet Set oSheet = ThisWorkbook.Worksheets(1) For i = 1 To 2000 oSheet.HPageBreaks.Add oSheet.Rows(i + 1) '<- Error when i=1027 Debug.Print i   Next End Sub

Additional query words: page break pagebreak hpagebreaks XL2003 XL2007

Keywords: kbdtacode kbinfo KB284916

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.