Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Determining if Calculation is Necessary.
by Allen Wyatt
(last updated December 28, 2013)
Excel allows you to control when it recalculates a worksheet. Normally, Excel recalculates anytime you change something in a cell. If you are working with very large worksheets that have lots of formulas in them, you may want to turn off the automatic recalculation feature. You can turn off automatic recalculation using controls on the Calculation tab of the Options dialog box.
Your macros can also force Excel to recalculate your worksheet. If you have automatic recalculation turned on, then any change your macro makes in a worksheet will force Excel to recalculate. If you have automatic recalculation turned off, then you can use the Calculate method to recalculate a worksheet:
Of course, if recalculation takes quite a while to perform, you might want to check to see if a recalculation is necessary before actually forcing one. It appears that there is no flag you can directly check to see if a recalculation is necessary. The closest thing is to check the Workbook object's Saved property. This property essentially acts as a "dirty flag" for the entire workbook. If there are unsaved changes in a workbook, then the Saved property is False; if everything is saved, then it is True.
How does this help you figure out if a recalculation is necessary? Remember that calculation is only necessary when there are changes in a worksheet. Changing anything in a worksheet will also set the workbook's Saved property to False. Thus, you could check the Saved property before doing the recalculation, as shown here:
If Not ActiveWorkbook.Saved Then ActiveSheet.Calculate End If
There is only one problem with this approach, of course—the Saved property is only set to True if the workbook is actually saved. This means that you could recalculate multiple times without really needing to do so, unless you tie saving and recalculation together, as shown here:
If Not ActiveWorkbook.Saved Then ActiveSheet.Calculate ActiveWorkbook.Save End If
The wisdom of approaching this problem in this manner depends on the nature of your particular situation. If it takes longer to save the workbook than it does to simply recalculate, then this approach won't work. If, however, recalculation takes longer (which is very possible with some types of operations), then this approach may work well.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2323) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Determining if Calculation is Necessary.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
You may need to automatically generate unique numbers when you create new worksheets in a workbook. Here's a couple of ...Discover More
Using macros to step through each cell in a selection is a common occurrence. What if that selected range is made up of ...Discover More
The macro programming language used in Excel gives you a great many tools that allow you to modify the way that Excel ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.