Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "Delay" function in Excel

Hello,
i would like to know if there is a way to have a (non-freezing, it has
to NOT freeze Excel) delay function in Excel (beside the loop with
DoEvents).

The problem is that i have a Macro that must "sleep" for 1 second, then
run, then sleep for 1 second, then run, and so on... but with a DoEvents
loop between each execution the CPU use is ALWAYS 100%.

Is there a not so CPU-hungry way to do it?

Thank you,
Luca
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default "Delay" function in Excel

hi,
pause a macro's excecution for a while.
Application.Wait (Now() + TimeValue("0:00:01"))

-----Original Message-----
Hello,
i would like to know if there is a way to have a (non-

freezing, it has
to NOT freeze Excel) delay function in Excel (beside the

loop with
DoEvents).

The problem is that i have a Macro that must "sleep" for

1 second, then
run, then sleep for 1 second, then run, and so on... but

with a DoEvents
loop between each execution the CPU use is ALWAYS 100%.

Is there a not so CPU-hungry way to do it?

Thank you,
Luca
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default "Delay" function in Excel

Hi Luca;

This is a copy of the VBA help for the Timer method. You
should be able to combine it with DoEvents to get what you
want.

Timer Function Example
This example uses the Timer function to pause the
application. The example also uses DoEvents to yield to
other processes during the pause.

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes
Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If





Thanks,

Greg
-----Original Message-----
Hello,
i would like to know if there is a way to have a (non-

freezing, it has
to NOT freeze Excel) delay function in Excel (beside the

loop with
DoEvents).

The problem is that i have a Macro that must "sleep" for

1 second, then
run, then sleep for 1 second, then run, and so on... but

with a DoEvents
loop between each execution the CPU use is ALWAYS 100%.

Is there a not so CPU-hungry way to do it?

Thank you,
Luca
.

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
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel 2003: Conditional Formatting using "MIN" & "MAX" function MMangen Excel Discussion (Misc queries) 2 September 16th 08 07:13 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
function to return day in the form "Monday", "Tuesday" etc given . MTro Excel Worksheet Functions 2 October 3rd 07 09:49 AM
inserting a conditional "go to" command on a excel "if" function velasques Excel Worksheet Functions 5 March 10th 06 08:16 PM


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