Written by Allen Wyatt (last updated April 29, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
Greg has several Excel workbooks that he uses on a regular or daily basis. But one is acting strange. The file consists of 14 worksheets. When he presses the Save button (either on the Quick Access Toolbar or File/Save) it shows the hourglass for a brief second. Then Greg immediately presses the Close button (top right "X" or File/Close) and Excel asks if he wants to save the file. This is the only workbook that does this; all of Greg's other workbooks close without asking him to save a second time. He wonders why this one file would be doing this.
Internally, Excel maintains what is known, at least colloquially, as a "dirty flag." In most simple terms, this is a True/False indicator as to whether something in the workbook has changed since the last time the workbook was saved. If something changes, then the flag is set to True. When you choose to close the workbook, Excel checks this flag and, if it is True, it asks you if you want to save your changes before closing.
So, in the case of Greg's workbook, the first culprit to suspect is something that is setting this dirty flag, making Excel think that something has changed in the workbook. This could be a macro that is changing something. For instance, there might be an event handler in the workbook that is run every time a different cell is selected. Or, perhaps there is a Workbook_BeforeClose event handler in place. Either way, the event handler may trigger within Excel the idea that something has changed within the workbook.
The only way to figure out if it is a macro is to do some detective work and examine the macros that may be saved in the workbook. Of course, this all assumes that the workbook is saved as macro-enabled, with the XLSM filename extension. If this is how the workbook is saved, then an easier way to figure out if a macro is involved is to follow these general steps:
Of course, if there are macros causing the issue, then it is possible those macros are necessary for proper functioning of the workbook in the first place. Further testing with the workbooks (both XLSM and XLSX formats) will be necessary to make that determination.
There are other things besides macros that could be causing Excel to think the workbook should be saved again. This has to do with what Excel terms "volatile functions," which are functions that, during recalculation, are automatically updated. This would set the dirty flag, and thereby make Excel think your workbook has to be saved again. You can learn about volatile functions at this Microsoft page:
https://learn.microsoft.com/en-us/office/client-developer/excel/excel-recalculation#volatile-and-non-volatile-functions
Of course, the entire irritation could be avoided if Greg simply changes his exiting routine—skip the step of saving and just close the workbook. If anything has changed in the workbook, Excel asks you if you want to save, and you can save at that point. In this approach you are relying on Excel to keep track of when saving is necessary and when it is not, which (as you now know) is something that Excel is going to do in any case.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9765) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.
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 want to add, to your worksheet, the date on which a particular workbook was created. Excel doesn't provide a way ...
Discover MoreAs you work with a workbook over time, it is possible for the workbook to grow to a huge size. If you want to shrink the ...
Discover MoreWhen you need to work on a workbook, you may want to do so without modifying the original contents of the workbook. This ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-04-29 07:55:27
Alex Blakenburg
A circular reference will behave in a similar manner to a volatile function.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments