Run macro at specified time

  • Thread starter Thread starter mushy_peas
  • Start date Start date
M

mushy_peas

Can someone please tell me how:-

1. Auto save a spreadsheet at a particular time or interval

2. Run a macro at a particular time.

Cheers
 
Mushy,

You may want to play with Application.OnTime

Sub ScheduleMe()
Application.OnTime Now() + TimeValue("00:00:05"), "RunMe"
End Sub

Sub RunMe()
Beep
ScheduleMe
End Sub


Rob
 
im sure i saw somewhere where it was really ease, it was just like one
line. basically do this at this time and that was it.

Chips, that all looked too much for me little brain too habdle. Hmm oh
well, i'll see.

Thanks anyway :O)
 
Maybe you didn't see my first post?:

Mushy,

You may want to play with Application.OnTime

Sub ScheduleMe()
Application.OnTime Now() + TimeValue("00:00:05"), "RunMe"
End Sub

Sub RunMe()
Beep
ScheduleMe
End Sub


Rob
 
hello Rob,
sorry, i did see your post and i did play with it.

It makes a beeping sound after 5 seconds repeatldy. Which is very
useful thank you.

I want something that will run at !7:00 every day, regarless of when
the application is firsted used.

I could figure an easy way to do that.
 
Mushy,

Sub test()
Application.OnTime CDate("1-Feb-2004"), "RunMe"
End Sub

Sub RunMe()
Beep
End Sub

Rob
 
That is an interesting concept - have you tested it? The help would seem to
indicate otherwise.

Schedules a procedure to be run at a specified time in the future (either at
a specific time of day or after a specific amount of time has passed).

Neither seems to indicate a date would be acceptable (a number greater than
1), but I will admit I have never tested it.

--
Regards,
Tom Ogilvy

Rob van Gelder said:
Mushy,

Sub test()
Application.OnTime CDate("1-Feb-2004"), "RunMe"
End Sub

Sub RunMe()
Beep
End Sub

Rob
 
Tom,

You're right - the documentation does seem to indicate arguments should be
Time values only.

DateTimes work too - maybe this is an undocumented feature ;)

Rob


Tom Ogilvy said:
That is an interesting concept - have you tested it? The help would seem to
indicate otherwise.

Schedules a procedure to be run at a specified time in the future (either at
a specific time of day or after a specific amount of time has passed).

Neither seems to indicate a date would be acceptable (a number greater than
1), but I will admit I have never tested it.
 
how about days of the week
for example i want to run a particualr marco at diff times in the day
depending if its Mon - Thurs, and another for Sat-Su
 
When you reschedule, you'll need to calculate the next Monday, Tuesday,
Saturday or whatever day you want the macro to run.

Be aware that OnTime does not persist after you've closed Excel. The macro
only runs if Excel is running too.
You need to reset OnTime every time you open the workbook.

Rob
 
Back
Top