Conditional macro execution

  • Thread starter Thread starter Willis Marsh
  • Start date Start date
W

Willis Marsh

Is there a way I can fire a macro based on time of day?
i.e 08:10

Thanks in advance,
 
Willis Marsh said:
Is there a way I can fire a macro based on time of day?
i.e 08:10

Thanks in advance,

Hi Willis... this was posted by Rob van Gelder it may be of some help...

seeya ste

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

Sub RunMe()
Beep
ScheduleMe
End Sub
 
The problem with this code is that there is no way to terminate
the loop. How would you ever stop RunMe from rescheduling itself
without terminating Excel? You should store the run time in a
public variable, and use the value of that variable in the OnTime
procedure. See www.cpearson.com/excel/ontime.htm for details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
-----Original Message-----
The problem with this code is that there is no way to terminate
the loop. How would you ever stop RunMe from rescheduling itself
without terminating Excel? You should store the run time in a
public variable, and use the value of that variable in the OnTime
procedure. See www.cpearson.com/excel/ontime.htm for details.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

be of
some help...


.
Thanks for the help.
Sub ScheduleMe()
Application.OnTime TimeValue("08:10:00"), "SaveWorksheet
()"
End Sub
Works just fine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top