November 25th, 2002, 11:18 am
How about a self validating WorkBook ?This code will stop your sheet saviung unless/until the TimeStamp stuff I use in my last post is later than the opening time of the sheet.IE if there is a cell in this range, not recalculated since opening, the workbook will just try to save itself, until it is.I pick 5 seconds for the retry attempt, but your mileage will vary.This is not a "busy wait", processing will occur whilst the sheet is waiting for the predicate to become true, and of courseyou can use more complex logic to decide when to close, for instance #VALUE!'s may need correcting.Bung this stuff in your "ThisWorkBook" ModuleDim Opened As DatePrivate Sub Workbook_Open()Opened = Date + TimeMsgBox "opening"End SubPrivate Sub Workbook_BeforeClose(Cancel As Boolean)Dim LastUpdate As DateIf Opened = 0 Then Exit SubLastUpdate = Names("MinTime").RefersToRange.Value'If has not changed since openingIf LastUpdate < Opened Then Cancel = True Application.OnTime Now + TimeValue("00:00:5"), "TryToClose"Else Debug.Print "really closing" Opened = 0End IfEnd Sub'Drop this in a modulePrivate Sub TryToClose()Debug.Print "Closing"Workbooks(1).Close Application.OnTime Now + TimeValue("00:00:5"), "TryToClose"End Su