Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
SW SW is offline
external usenet poster
 
Posts: 12
Default Pause a macro by resetting current time

Hi, I am creating a macro which changes the y-values in a distribution plot
each second (corresponding to the values the next day). This allows one to
see a distribution change over time. The problem I have is I found the
following code to pause in between (so one can see the distribution shifting
over time) the dates but it pauses it for 1 second and I need it to pause it
for about half a second only.
Here is the code (for pausing) that I currently have:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

Any help greatly appreciated, thanks a million!
SW
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Pause a macro by resetting current time

Use this procedure to wait and call in your code

Wait (0.5)

Sub Wait(sngDelayInSecs As Single)
EndDelay = Timer + sngDelayInSecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"SW" wrote:

Hi, I am creating a macro which changes the y-values in a distribution plot
each second (corresponding to the values the next day). This allows one to
see a distribution change over time. The problem I have is I found the
following code to pause in between (so one can see the distribution shifting
over time) the dates but it pauses it for 1 second and I need it to pause it
for about half a second only.
Here is the code (for pausing) that I currently have:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

Any help greatly appreciated, thanks a million!
SW

  #3   Report Post  
Posted to microsoft.public.excel.programming
SW SW is offline
external usenet poster
 
Posts: 12
Default Pause a macro by resetting current time

Get it!
Works fantastically thanks so much!

"Jacob Skaria" wrote:

You can use

Wait (0.5) for delay...

Sub Wait() should be copied separately...may be after End Sub of your
existing macro
--
If this post helps click Yes
---------------
Jacob Skaria


"SW" wrote:

Thanks v much,
I should have mentioned I am no programmer and do most of this by recording
and editing macros etc at the moment.
I copied and pasted your code into mine but it did not work - do I need to
change something else?
Thanks again,
SW

"Jacob Skaria" wrote:

Use this procedure to wait and call in your code

Wait (0.5)

Sub Wait(sngDelayInSecs As Single)
EndDelay = Timer + sngDelayInSecs
Do While Timer < EndDelay
DoEvents
Loop
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria


"SW" wrote:

Hi, I am creating a macro which changes the y-values in a distribution plot
each second (corresponding to the values the next day). This allows one to
see a distribution change over time. The problem I have is I found the
following code to pause in between (so one can see the distribution shifting
over time) the dates but it pauses it for 1 second and I need it to pause it
for about half a second only.
Here is the code (for pausing) that I currently have:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

Any help greatly appreciated, thanks a million!
SW

  #4   Report Post  
Posted to microsoft.public.excel.programming
SW SW is offline
external usenet poster
 
Posts: 12
Default Pause a macro by resetting current time

This works too - thanks v much.

"Gary''s Student" wrote:

Sub servient()
Application.Wait Now() + 0.000005787037
End Sub
--
Gary''s Student - gsnu200846


"SW" wrote:

Hi, I am creating a macro which changes the y-values in a distribution plot
each second (corresponding to the values the next day). This allows one to
see a distribution change over time. The problem I have is I found the
following code to pause in between (so one can see the distribution shifting
over time) the dates but it pauses it for 1 second and I need it to pause it
for about half a second only.
Here is the code (for pausing) that I currently have:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

Any help greatly appreciated, thanks a million!
SW

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
Pause a macro by resetting current time SW Excel Programming 1 April 16th 09 02:05 PM
Pause a macro by resetting current time Gary''s Student Excel Programming 0 April 16th 09 02:00 PM
Stop / Pause a Macro using Pause button scott56hannah Excel Programming 0 June 27th 08 12:48 PM
Pause a macro for some time [email protected] Excel Programming 3 January 2nd 07 02:34 PM
macro for current time mangesh Excel Discussion (Misc queries) 0 March 21st 06 08:22 PM


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