#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default ontime code

Thanks Jacob.

I found something that Chip Pearson had made a while back too, and that did
the trick.


"Jacob Skaria" wrote:

Hi Steve

Insert a module and paste the below procedures and try.

Sub AutoRunMe()
Application.OnTime Now + TimeSerial(0, 0, 10), "MyMacro"
End Sub

Sub MyMacro()
MsgBox Now
Call AutoRunMe
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Steve" wrote:

Morning all.
I'm interested in doing an "autorun" macro that will run every few minutes,
to every couple of hours.
I've looked around here on the newsgroup, and the various forums, and found
some examples, but in the application of them, I don't seem to get what I
want. See code....

Sub AutoRunMe()
application.ontime now + timeserial(0, 0, 10), "MyMacro"
end sub

In my reading, it states that the above code will run every 10 seconds,
following an initial start time of "now."

If however I do this:

application.ontime timeserial( 0, 0, 10), "MyMacro"

it'll only run at 10 seconds past midnight.

I also tried now + timevalue("00:00:10"); it's not repeating every 10
seconds either.


What I'm finding is that the first one does not run every ten seconds-- I
tried it just to make sure it'll do what I need-- and I cannot find anything
else that will allow me to run the macro every few minutes or hours, as I
decide.

I realize that I don't entirely understand it, so I wanted to ask-- how do I
create a macro that'll run every few minutes or so?

Thank you.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default ontime code

Thanks Steve/Chip

You can adjust the code to run a number of iterations or upto a a certain
time keeping Ontime within a loop and specifying the iterations or the end
time as a global variable.

If this post helps click Yes
---------------
Jacob Skaria


"Steve" wrote:

Thanks Jacob.

I found something that Chip Pearson had made a while back too, and that did
the trick.


"Jacob Skaria" wrote:

Hi Steve

Insert a module and paste the below procedures and try.

Sub AutoRunMe()
Application.OnTime Now + TimeSerial(0, 0, 10), "MyMacro"
End Sub

Sub MyMacro()
MsgBox Now
Call AutoRunMe
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Steve" wrote:

Morning all.
I'm interested in doing an "autorun" macro that will run every few minutes,
to every couple of hours.
I've looked around here on the newsgroup, and the various forums, and found
some examples, but in the application of them, I don't seem to get what I
want. See code....

Sub AutoRunMe()
application.ontime now + timeserial(0, 0, 10), "MyMacro"
end sub

In my reading, it states that the above code will run every 10 seconds,
following an initial start time of "now."

If however I do this:

application.ontime timeserial( 0, 0, 10), "MyMacro"

it'll only run at 10 seconds past midnight.

I also tried now + timevalue("00:00:10"); it's not repeating every 10
seconds either.


What I'm finding is that the first one does not run every ten seconds-- I
tried it just to make sure it'll do what I need-- and I cannot find anything
else that will allow me to run the macro every few minutes or hours, as I
decide.

I realize that I don't entirely understand it, so I wanted to ask-- how do I
create a macro that'll run every few minutes or so?

Thank you.

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
Find %ontime & SUMIF ontime ie: find matching sets within Range... Chris T-M Excel Worksheet Functions 3 October 10th 08 08:14 PM
OnTime code error "can't execute code in break mode" tskogstrom Excel Programming 1 September 8th 06 10:29 AM
OnTime jimmike1 Excel Programming 2 February 2nd 06 04:31 PM
about ontime uma[_2_] Excel Programming 0 January 21st 06 06:33 AM
OnTime gottahavit Excel Programming 2 January 12th 06 06:26 PM


All times are GMT +1. The time now is 11:55 PM.

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

About Us

"It's about Microsoft Excel"