Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining if Calculation is Necessary.

Determining if Calculation is Necessary

Written by Allen Wyatt (last updated December 9, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


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 the tools in the Calculation group on the Formulas tab of the ribbon.

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:

ActiveSheet.Calculate

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.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5685) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Determining if Calculation is Necessary.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Protecting Parts of a Document

Word doesn't require you to protect entire documents. Instead, you can protect different sections within a document, as ...

Discover More

Using Find and Replace to Change Text Case

Can you really use Find and Replace to change the case of text in your document? Not really, but that shouldn't stop you ...

Discover More

Creating a Lorem Ipsum Tool

When editing, you may need random placeholder text inserted in your document. Word provides a couple of ways you can do ...

Discover More

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!

More ExcelTips (ribbon)

Specifying a Delimiter when Saving a CSV File in a Macro

You can, within a macro, save a workbook in several different file formats that are understood by Excel. However, you may ...

Discover More

Adding Leading Zeroes to ZIP Codes

Import a bunch of ZIP Codes into Excel, and you may be surprised that any leading zeroes disappear. Here's a handy little ...

Discover More

Conditionally Displaying a Message Box

You can, from within your macros, easily display a message box containing a message of your choice. If you want to ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.