Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. 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: Saving Non-Existent Changes.

Saving Non-Existent Changes

by Allen Wyatt
(last updated April 29, 2020)


You probably had this happen to you: You open a workbook, look around at some of the worksheets, and then close the workbook. As part of closing, Excel asks you if you want to save your changes, yet you didn't make any changes—you only looked around. What gives?

Internally, Excel maintains what is commonly called a "dirty flag." This flag gets set whenever you do some sort of change to a workbook. Whenever you save the workbook, the flag is cleared. If the flag is set when you close the workbook, Excel asks if you want to save the workbook.

The dirty flag can obviously get set if you make some explicit change to a workbook, such as editing a cell or modifying the structure of the workbook in some way. However, it can also get set even if you don't do anything explicit. Sometimes, Excel does something that affects the contents of the workbook just by virtue of the fact you opened it. This sets the dirty flag and thus triggers the request about saving.

Two big culprits in making such automatic changes are the TODAY and NOW worksheet functions. These return the system date and the system time, respectively. When you first open a workbook, they are updated in the normal course of recalculating. Since they represent a change, Excel sets the dirty flag. These are only two possible culprits; there are other functions that can have the same "this workbook has been changed" effect. A non-exhaustive list includes INDIRECT, OFFSET, RAND, and RANDBETWEEN.

The dirty flag can also be set automatically if your workbook includes links to data on other worksheets. Excel retrieves the data, which represents a change to the workbook you just opened. Excel doesn't set the dirty flag if you simply navigate around the workbook, doing things like selecting cells or changing to a different worksheet.

One way you can get around the problem is to remove whatever is causing changes in your workbook. For most people, this just isn't practical. You can also add an automatic macro that will run just before the workbook closes, such as the following, which should be part of the ThisWorkbook object:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ActiveWorkbook.Saved = True
End Sub

This macro does nothing more than clear the dirty flag (the Saved property). While this approach will work, there is a huge risk inherent in using it. With the macro in place, Excel will never ask you if you want to save changes upon exiting, even if legitimate changes were done to the workbook. Thus, you would need to remember to explicitly save anything in the workbook whenever you make changes. If you don't, you may lose some of your work.

A variation on this approach—one that is less unforgiving of forgotten changes—is to actually make the macro part of the Workbook_Open procedure for the ThisWorkbook object:

Private Sub Workbook_Open()
    ActiveWorkbook.Saved = True
End Sub

Now, Excel opens the workbook, recalculates (including making changes based on functions such as TODAY and NOW), and then clears the dirty flag. If you close right away, you aren't asked if you want to save your changes. You will be asked if you want to save changes, however, if you make changes after this macro has run—in other words, after the worksheet was fully opened.

Besides automatically recalculating functions that set the dirty flag, it is also possible that your workbook contains a macro or two that automatically run when you open it. If the macro is making some sort of change in the workbook, then it will naturally set the dirty flag. You can check out the VBA Editor to see if this is the case.


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 (12352) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Saving Non-Existent Changes.

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. ...


Selecting a Specific Cell in a Macro

Need to use a macro to select a specific cell in a different workbook? It's not as straightforward of a proposition as ...

Discover More

Tying Workbooks Together

If you work with multiple workbooks at the same time, you might wonder how to tie them together so they open and close at ...

Discover More

Converting Phone Numbers

Sometimes you receive a phone number that contains alphabetic characters and you need to convert it to a purely numeric ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Weird Actions for Arrow Keys and Enter

If your arrow keys and the Enter key aren't working as you expect them to, the problem could have any number of causes. ...

Discover More

Excluding a Specific Add-In at Startup

Got an add-in that you don't want loaded each time that Excel starts up? Here are a few ways that you can exclude it.

Discover More

Fixing a Numeric Keypad Key

We all expect the keyboard keys to operate as normal, and when they don't, it can be bothersome. Geraldine had such a ...

Discover More

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

View most recent newsletter.


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 7 + 7?

2018-07-15 08:45:43

MIchael Armstrong

I normally have a bunch of workbooks open; nearly all of them are "saved". But if Windows Update has reared its ugly head, and rebooted my PC, there are two entries in the recovery list for every workbook - the original "saved by..." and the autosaved version. One wonders why autosave couldn't inspect the dirty flag and only autosave the "dirty" ones. This would make restarting after a reboot a lot simpler.

2018-07-14 10:59:18

Mike L

Isn't the most common setting of the dirty flag due to a different printer is found on this opening than previously?

2017-06-14 06:45:06

c vernon

very nice explanation. thank you.

2016-12-14 17:01:21


When you are doing a lot of multi-tasking and have several workbooks open, it is not possible to keep a mental note of whether a change was made.

2016-12-13 05:55:49


Why not just click "yes" or "no"?

2016-12-12 17:30:57



I'm using Excel for Mac version 15.29 (161204). My workbook does not contain the TODAY or NOW functions. It also doesn't contain INDIRECT, OFFSET, RAND, or RANDBETWEEN.

There are also no external links.

But it still prompts me to save as soon as I open the file. What can be done to address this without creating a Macro?

2016-11-25 12:31:39

Phil Greiner

This is an excellent article - right to the point, thorough, and no fluff. Thanks.

2016-09-11 05:28:30



There are a couple of reasons for the macro not running.

Firstly, the security settings must allow macros to be run (and the workbook is opened without the Shift key being depressed). Excel security settings are critical to this, but are dependent upon whether or not the macros are digitally signed, and whether the workbook file is in a designated "trusted" location.

Secondly, the macro must placed on the "ThisWorkbook" codepage.

2016-09-10 19:19:10

Lluís Albert

Hi, thanks for information. I'm trying this solution in my vba project. It is not running :(

Initially I tried code in OPEN section of Workbook:

Private Sub Workbook_Open()
ActiveWorkbook.Saved = True
End Sub

But it is not running ok :(

After that, I put a button for testing on sheet, with same codee: ActiveWorkbook.Saved = True and when you press "X" to close Excel, appears message for saving it... :S

Please, help me!

2016-09-10 12:27:53


I habitually perform two steps when I am finished with a workbook: 1) save it, then 2) closed it. There is one workbook at the office that always asks if I want to save my changes before closing, although I just did that. Even after reading this tip, I find that example a bit strange.

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

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.