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

Finding Long Lines

Word is very dynamic in how it "flows" text from one line to another and one page to another. In most cases we are ...

Discover More

Creating a Single Index from Multiple Documents

When dealing with large projects, it is not uncommon to break the project into multiple documents. When it comes time to ...

Discover More

Setting Minimums and Maximums when AutoFitting Column Widths

Using AutoFit can help you maximize your use of screen space. In certain situations, though, it can make your data harder ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Putting the Last Saved Date in a Cell

Do you need a cell in your worksheet to display the date on which the workbook was last saved? This can be a bit tricky, ...

Discover More

Worksheet Events

You can create macros that are automatically executed whenever certain events occur within a worksheet. This tip details ...

Discover More

Copying Data between Worksheets Using a Macro

Macros can be used for all sorts of data processing needs. One need that is fairly common is the need to copy data from ...

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 five more than 3?

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.