one-tenth of a second delay

M

matt dunbar

hi all

a really useful & simple bit of code introduces a one second delay
within a macro

Range("A1").Select
Application.Wait (Now + TimeValue("0:00:01"))
Range("A1").Select

can anybody trump this with a bit of code that gives a one-tenth of a
second delay please?

or is this the holy grail of code?

rise to the challenge please!?

TIA

matt
 
R

Rob van Gelder

On my website is a link to "Subsecond Wait"

Code here for caching reference:

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub test()
Sleep 500 'wait 1/2 second
End Sub
 
J

JWolf

Application.wait (now + 0.0000011574074074)
Excel time values are stored to the right of the decimal point of the date.
The whole number is the number of days since 1/1/0 or 1/1/04 (depending
on system )
The fraction after the decimal point is the number of seconds since
midnight divided by
86400. (24 hrs * 60 minutes * 60 seconds = 86400 seconds per day).
Divide any exact time including fractional seconds by 86400 to get its
serial value.
 
D

dasobrinski

try this
Application.Wait (Now + TimeValue("0:00:01")/2)

it is closer to one tenth of a second. if i remember
correctly i don't think it changes if you increase the 2
value.
 
R

Rob van Gelder

As I understand it, Application.Wait does not do resolutions finer than 1
second.
If you ask it to wait until Now+1s, then that point in time may already be
1/2 a second away (or it may be a 1/10 second away or even 9/10 second away)
 

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