Pause a macro by resetting current time

S

SW

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
 
J

Jacob Skaria

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
 
S

SW

Get it!
Works fantastically thanks so much!

Jacob Skaria said:
You can use

Wait (0.5) for delay...

Sub Wait() should be copied separately...may be after End Sub of your
existing macro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top