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: Saving Non-Existent Changes.

Saving Non-Existent Changes

by Allen Wyatt
(last updated February 16, 2016)

6

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.

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, of course, 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 loose 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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2081) 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: 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. ...

MORE FROM ALLEN

Unlinking an Excel Chart Automatically

When Excel charts are linked in a Word document, they update every time the document is opened. Here's how to unlink the ...

Discover More

Normal Words Flagged by Spell Check

What do you do when Word's spelling check marks some common, everyday words as wrong? Here are some ideas of places you can ...

Discover More

Copying Custom Properties

You can add custom properties to a document to help with all sorts of file management tasks. If you want to copy these custom ...

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 (menu)

Disabling the Insert Key

Tap the Insert key and you can start overwriting information already in a cell. If you don't want to do this, one way to ...

Discover More

Changing Error Checking Rules

Excel can check the data and formulas in your worksheet to see if it detects any errors. The rules used for this checking can ...

Discover More

Automatic Recalculation Not Happening

Excel 97, under certain circumstances, has a problem recalculating worksheets reliably. This tip tells you how to patch that ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 6 - 3?

2017-06-22 07:00:19

Adrienne

this discussion is pretty much consistent with others on the topic. However, I think that none of it applies to my case. I ran a test in which I opened a workbook with none of the characteristics that trigger a save question. In the first instance I did absolutely nothing, and I did not get the save question. in the second instance all I did was copy the contents of a cell to the clipboard. In the latter case I did get a save question. Someone please explain that in the context of this topic.


2017-05-04 04:04:29

Michael (Micky) Avidan

@Allen,
You forgot all about: RAND and RANDBETWEEN being "Super Volatile" and as Bruno mentiond: OFFSET & INDIRECT.
--------------------------
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2017)
ISRAEL


2017-05-03 18:45:35

Tod Gordon

All I did was this -

1. Open up new workbook in Excel 2016 by choosing blank workbook type.
2. Type the word "test" in a few cells.
3. Save file and exit Excel
4. Reopen Excel and the new workbook I created.
5. Move the current active cell to another one.
6. Try to exit - Voila, it asks if I want to save.

No formulas, no fancy stuff, nada. Just move to another cell.


2017-01-05 13:45:06

Mike Rees

@kidshelleen51 - I was all excited when I read your comment as I have a pile of SUMIF functions in my spreadsheet, but alas, that wasn't my problem. I'm so frustrated with this document! There are no volatile functions, no macros, nothing, and it constantly asks me to save before closing. I'm going insane.


2016-11-29 15:14:16

kidshelleen51

I finally found the cause of my issue with this. I am using a lot of "sumif" formulas and in a couple of them the 2 ranges were not the same. In other words I had a formula like this: = SUMIF(I155:I178,I155,L155:L177). As soon as I corrected that last number to be L178, the problem went away.


2015-08-21 08:37:41

Bruno

Surprisingly, array formulas combined with offset or indirect also generate this behavior without even selecting a new cell when opening the worksheet. Weird !


This Site

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.

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.