This article was previously published under Q145598
This article has been archived. It is offered "as is" and will no longer be updated.
When you run a Visual Basic for Applications macro in Microsoft Excel 97,the macro may take longer to complete than it does in earlier versions ofExcel. For example, a macro that required several seconds to complete in anearlier version of Excel may require several minutes to complete inMicrosoft Excel 97.
This problem may occur if the following conditions are true:
Your Visual Basic macro modifies the properties of many rows.
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.
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 youmanually set a PageSetup property, and you then run a Visual Basic macrothat sets properties on a large range of rows. Setting PageSetup propertiesturns on automatic calculation of page breaks in Microsoft Excel 97. Bydefault, this property is not turned on.
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:
On the Tools menu, click Options.
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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers 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 requirements. To work around the problem, add the following line of code to your VisualBasic macro:
ActiveSheet.DisplayPageBreaks = False
NOTE: This line of code must be inserted after you modify any of theproperties of the PageSetup object, but before you modify the properties orthe rows on your worksheet.
For more information about this problem, please see the following articlein the Microsoft Knowledge Base:
164919XL97: Scrolling Through Worksheet Causes MS Excel to Pause
For more information about worksheet properties, please see the followingarticle in the Microsoft Knowledge Base:
169106XL97: Some Worksheet Properties not Preserved