PDA

View Full Version : repeate an action



lior03
12-05-2005, 11:54 AM
hello
the following macro will save and close all open workbooks except the active workbook within 15 seconds.how do i make it repeate it's action?.
namely- how do i create my on autosave mechanism.
Sub doit2()
Dim dnext As Date
dnext = TimeValue("00:00:15")
Application.OnTime Now + dnext, "closeallbut"
End Sub

thanks

Jacob Hilderbrand
12-05-2005, 12:13 PM
Just call the same sub with ontime. So it will keep calling itself.


Option Explicit

Sub a()

MsgBox "Hi"
Application.OnTime Now + TimeSerial(0, 0, 2), "a"

End Sub

lior03
12-05-2005, 10:43 PM
hello
could you be more specific.your macro do not work.
thanks

Jacob Hilderbrand
12-06-2005, 12:00 PM
You can just copy my code to a module in the VBE, then run it. The message box will keep poping up every 2 seconds.