D
Dominic
Want the excel file to open so the date-dependent formulas refresh to the new
month. Then save the file. Can this be done?
month. Then save the file. Can this be done?
Gord Dibben said:See Chip Pearson's site for OnTime method.
http://www.cpearson.com/excel/OnTime.aspx
Here is an example using Chip's procedures.
In a General Module..........................
Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "TheSub"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
End Sub
Sub Example_Macro()
ActiveSheet.Range("A1:F10").Interior.ColorIndex = 3
End Sub
Sub TheSub()
ThisWorkbook.Save
StopTimer
Application.Quit
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=False
End Sub
In Thisworkbook Module..............................
Private Sub Workbook_Open()
Example_Macro 'runs the macro
StartTimer 'starts the timer to save workbook and shut down Excel
End Sub
I''ll leave it to you to figure out a way to prevent macro warning when
workbook opens.
Gord