View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Zone[_2_] Zone[_2_] is offline
external usenet poster
 
Posts: 43
Default Wait Seconds and Tenths

JLG, Strange that mine wouldn't work for you. The solution suggested by
Chip is surely much more accurate, delay-wise, but I liked mine because it's
so darned simple. It's maybe the Do Events that's causing the problem (?).
You could rem out that line and try again. Or/and put it in a new file and
try it by itself. It seems to work surprisingly well for me. Cheers, James
"JLGWhiz" wrote in message
...
Zone, couldn't get yours to work with my application:

Counter = 1
Do Until Counter = 37
MyClrValue = Int((55 * Rnd) + 1)
Worksheets(2).Range(Cells(Counter, 1), Cells(Counter,
16)).Interior.ColorIndex = MyClrValue
'Here is where I need about a half second,
'or maybe quarter second delay.
Counter = Counter + 1
Loop

Without the delay it looks like all the colors appear at once and I want
the
waterfall effect.

"Zone" wrote:

Thanks, Chip. Even better! James
"Chip Pearson" wrote in message
...
Zone,

Try the following code:

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub FallAsleep()
Dim Seconds As Long
Dim Tenths As Long
Dim SleepTime As Double
Seconds = Range("A1").Value
Tenths = Range("B1").Value
SleepTime = ((Seconds * 1000) + (Tenths * 100))
Debug.Print "Ready To Sleep: " & CStr(SleepTime)
Sleep dwMilliseconds:=SleepTime
Debug.Print "Wake Up"
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Zone" wrote in message
ps.com...
I want to put a whole number in a cell, say A1, to represent seconds,
and another whole number in a cell, say B1, to represent tenths (or
hundredths) of a second. How do I get my macro to pause for this
amount of time? Please specify type of any variables! Thanks, James