Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
kk kk is offline
external usenet poster
 
Posts: 5
Default chip pearson are you there pls, problem with your RunWhen

Hi, a relative newbie here, I have dutifully cut and pasted your
runwhen stuff from an earlier thread and your site, and have a
problem;

Sub timeron()

'run it at the time in brackets;
RunWhen = CLng(Now) + TimeValue("16:46:00") ' 11:20 PM today
'RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=True
End Sub

I use remark comma to switch from either the first RunWHen or the
second. When i do the second, the procedure cRunWhat runs the
specified 10 seconds after I have F8 tabbed thru it. When i rem out
the second RunWhen and use the first, then F8-tab right thru, nothing
happens. I've looked at the watch window, and RunWhen gets a long
number, eg now it is 37884.7041666667, and i have noticed that once i
have gone right thru the thing and then go to restart it, Runwhen
re-opens with the same value as soon as i start the sub, i.e. it is
already populated before i get to the runwhen line. Am i doing
something very obviously very wrong? Where I am hoping to get to by
the way is to set Runwhen so that at e.g. 0815 hours every day, or
even better every weekday, the thing runs automatically. will the
first runwhen line above reset itself to the same time every day
please?

thanks

k
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default chip pearson are you there pls, problem with your RunWhen

If you want the procedure to execute every day at 8:15 AM, just use

RunWhen = Date + 1 + TimeSerial(8, 15, 0)

already populated before i get to the runwhen line.


RunWhen is declared as a global variable, and retains its value even after
the procedure has ended.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com



"kk" wrote in message
om...
Hi, a relative newbie here, I have dutifully cut and pasted your
runwhen stuff from an earlier thread and your site, and have a
problem;

Sub timeron()

'run it at the time in brackets;
RunWhen = CLng(Now) + TimeValue("16:46:00") ' 11:20 PM today
'RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=True
End Sub

I use remark comma to switch from either the first RunWHen or the
second. When i do the second, the procedure cRunWhat runs the
specified 10 seconds after I have F8 tabbed thru it. When i rem out
the second RunWhen and use the first, then F8-tab right thru, nothing
happens. I've looked at the watch window, and RunWhen gets a long
number, eg now it is 37884.7041666667, and i have noticed that once i
have gone right thru the thing and then go to restart it, Runwhen
re-opens with the same value as soon as i start the sub, i.e. it is
already populated before i get to the runwhen line. Am i doing
something very obviously very wrong? Where I am hoping to get to by
the way is to set Runwhen so that at e.g. 0815 hours every day, or
even better every weekday, the thing runs automatically. will the
first runwhen line above reset itself to the same time every day
please?

thanks

k



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
PEARSON versus CORREL Stan Brown Excel Worksheet Functions 3 May 19th 23 11:43 AM
Ping Chip Pearson Lomax Excel Worksheet Functions 6 October 18th 05 01:21 AM
Thank you Chip Pearson Michael Excel Discussion (Misc queries) 3 February 5th 05 08:35 PM
Chip Pearson- you're web page is down scott Excel Discussion (Misc queries) 8 January 27th 05 11:49 PM
Chip Pearson or someone Chip Pearson Excel Programming 3 September 18th 03 05:22 AM


All times are GMT +1. The time now is 06:47 AM.

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"