Run a Macro at a certain time

J

jswalsh33

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
 
M

Mike H

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.
 
J

jswalsh33

Thanks Mike, That worked fine.

Jim Walsh

Mike H said:
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.
 

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

Top