Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Run a Macro at a certain time

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 51
Default Run a Macro at a certain time

Thanks Mike, That worked fine.

Jim Walsh

"Mike H" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro / function text time to 24hr excel time passed midnight fortotaling hr's Russmaz Excel Worksheet Functions 2 March 6th 09 04:58 AM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Time 24:00:00 in macro NC Excel Discussion (Misc queries) 2 March 11th 07 11:55 AM
Can I get a macro to run at a certain time of day? Nick123 Excel Discussion (Misc queries) 2 July 27th 05 11:31 AM


All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"