Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Excel limits the number of manual page breaks to 1026


Summary

Microsoft Office Excel has a limit of 1026 manual horizontal page breaks for a worksheet. In Excel 2007, a limit of manual page breaks is 1023. 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.

↑ Back to the top


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

↑ Back to the top


Keywords: kbfreshness2006, kboffice12yes, kboffice2003yes, kbswept, kbvs2003swept, kbdtacode, kbinfo, kb

↑ Back to the top

Article Info
Article ID : 284916
Revision : 1
Created on : 1/7/2017
Published on : 9/11/2009
Exists online : False
Views : 157