LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default OnTime LatestTime Use

Hi all,

Am using Excel 2010. I am trying to run a macro on just one day only,
anytime throughout the day starting from 09:30 onwards. But not run it
if the day has changed.

I have the following code in the Workbook_Open section:
RunTimeFirst = DateSerial(2012, 12, 9) + TimeSerial(9, 30, 0)
LastRun = RunFirstTime + 48600
Application.OnTime EarliestTime:=RunTimeFirst, _
Procedu="Birthday_Message", LatestTime:=LastRun, Schedule:=True

The problem I'm having is understanding the LatestTime parameter. The
help file states:
"The latest time at which the procedure can be run. For example, if
LatestTime is set to EarliestTime + 30 and Microsoft Excel is not in
Ready, Copy, Cut, or Find mode at EarliestTime because another procedure
is running, Microsoft Excel will wait 30 seconds for the first procedure
to complete. If Microsoft Excel is not in Ready mode within 30 seconds,
the procedure won’t be run. If this argument is omitted, Microsoft Excel
will wait until the procedure can be run."

Does LatestTime also stop the macro from running if LatestTime has
passed, or just pause for time while Excel is not in ready mode?
Is my LastRun declaration correct. Is the 48600 seconds like the help
file says, or another value? (days?)

When I run this now the macro will run everyday later than the
RunTimeFirst date, and seems to ignore LastRun time.

I know I can add an If statement to check the date:
If Now DateSerial(2012, 12, 10) Then Exit Sub

This will work, but I just wanted to know how LatestTime worked.

Thanks in advance,
edul
 
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 Gordon Humphreys[_2_] Excel Programming 1 May 24th 07 12:54 PM
about ontime uma[_2_] Excel Programming 0 January 21st 06 06:33 AM
OnTime...Please Help Michael_I Excel Programming 9 May 24th 04 07:56 PM
OnTime Help Mark Scholes Excel Programming 1 January 30th 04 03:48 AM


All times are GMT +1. The time now is 05:42 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"