XL2000: Macro Performance Slow When Page Breaks Are Visible

ID: Q199505


The information in this article applies to:
  • Microsoft Excel 2000


SYMPTOMS

When you run a Microsoft Visual Basic for Applications macro in Microsoft Excel, the macro may take longer to complete than it does in earlier versions of Excel. For example, a macro that required several seconds to complete in an earlier version of Excel may require several minutes to complete in Microsoft Excel 2000.

Or, if you run a macro a second time, it may take twice as long as it did the first time.


CAUSE

This problem may occur if the following conditions are true:

  • Your Visual Basic macro modifies the properties of many rows or columns.

    -and-

  • You have performed an operation that forced Excel to calculate page breaks. Excel calculates page breaks when you perform any of the following operations:

    • You display a print preview of your worksheet.
    • You click Page Setup on the File menu.
    • You modify any of the properties of the PageSetup object in a Visual Basic macro.

    -and-

  • You have selected the Page breaks check box on the View tab of the Options dialog box.
This problem occurs if your macro sets any PageSetup property, or if you manually set a PageSetup property, and you then run a Visual Basic macro that sets properties on a large range of rows or columns. Setting PageSetup properties turns on automatic calculation of page breaks in Microsoft Excel. By default, this property is not turned on.


WORKAROUND

To work around the problem, use either of the following methods.

Method 1: Manually Turn Off the Display of Page Breaks

To manually turn off the display of page breaks, follow these steps:

  1. On the Tools menu, click Options.


  2. Click the View tab. Under Window options, click to clear the Page breaks check box. Click OK.


Method 2: Turn Off the Display of Page Breaks in Your Macro

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp
To work around the problem, add the following line of code to your Visual Basic macro:

ActiveSheet.DisplayPageBreaks = False 

NOTE: This line of code must be inserted after you modify any of the properties of the PageSetup object, but before you modify the properties or the rows on your worksheet.

Additional query words:

Keywords : kbprint kbdta kbdtacode
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.