View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Run a Macro at a certain time

Hi,

To get the macro to run using ontime you have to start things off like this

Private Sub Workbook_Open()
Application.OnTime TimeValue("02:00:00"), "Merge"
End Sub

or you can put it in another sub and run that and at the alloted time your
macro will run

Sub Get_Things_Going()
Application.OnTime TimeValue("02:00:00"), "Merge"
End sub


Sub Merge()
'Your code
End Sub




--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"jswalsh33" wrote:

I have tried to use Mike H's answer to Running Excel macro as a service
dated 9/30/2008.

I have us the task Scheduler to open the Excel Workbook containing the macro
I want to run with a time of 2:00 AM.

When I put the code Application.OnTime TimeValue("02:01:00"), "Merge" as the
first line of the Macro Merge, nothing happens when 02:01:00 comes.

What am I doing wrong?

Jim Walsh