WAIT() function?

myspacee

New Member
Joined
May 18, 2005
Messages
25
Hello,
i must wait 5 seconds between an operation and another,
but can't find wait() function or similar...

Can someone help me?

A.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hello

In your code, add this declaration at the top of you code (below the 'Option' statements but before the first 'Sub'):
Code:
Private Declare Sub Sleep Lib "kernel32" _
    (ByVal dwMilliseconds As Long)

Then to activate a pause in your code of 5 seconds, use this:

Code:
Sleep 5000

The 'sleep' time is expressed in milliseconds hence a 5 second pause is shown as 5000 milliseconds.

HTH, Andrew
 
Upvote 0
Thank you for reply.

here my 2 solution:

- a temporized msgbox
(usage : msgboxtimed("hello world!")
-----------8<---------------------------------------------------------------------------------------------
Private Sub msgboxtimed(my_text As String)
Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

intReturn = objShell.PopUp(my_text, 3, "Temporized message : 3 sec.")

End Sub
----------->8-----------------------------------------------------------------------




- a while cicle
(usage : call waitforme )

----------->8-----------------------------------------------------------------------
Private Sub waitforme()
pausainsecondi = 5
Dim DelayEnd As Double
DelayEnd = DateAdd("s", pausainsecondi, Now)
While DateDiff("s", Now, DelayEnd) > 0
Wend
End Sub
-----------8<---------------------------------------------------------------------------------------------


Thank you all !

A.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top