Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Wait Seconds and Tenths

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Wait Seconds and Tenths

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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Wait Seconds and Tenths

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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Wait Seconds and Tenths

Sub EFG()
Dim counter As Long
Dim s As Single
counter = 1
Do Until counter = 37
MyClrValue = Int((55 * Rnd) + 1)
With Worksheets(2)
.Range(.Cells(counter, 1), _
.Cells(counter, 16)).Interior _
.ColorIndex = MyClrValue
End With
s = Timer + 0.5
Do While Timer < s
DoEvents
Loop
'Here is where I need about a half second,
'or maybe quarter second delay.

counter = counter + 1
Loop

End Sub


worked on my machine. Can't say it waits exactly half a second, but there
is a measurable pause.

--
Regards,
Tom Ogilvy


"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








  #5   Report Post  
Posted to microsoft.public.excel.programming
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










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Wait Seconds and Tenths

Thanks, Tom. Old Codgers can learn new tricks. I was trying to nest the
wrong kind of loop. Never tried the DoEvents thing before.

And Zone, glad you got yours working too.

Merry Crhistmas to all.

John

"Tom Ogilvy" wrote:

Sub EFG()
Dim counter As Long
Dim s As Single
counter = 1
Do Until counter = 37
MyClrValue = Int((55 * Rnd) + 1)
With Worksheets(2)
.Range(.Cells(counter, 1), _
.Cells(counter, 16)).Interior _
.ColorIndex = MyClrValue
End With
s = Timer + 0.5
Do While Timer < s
DoEvents
Loop
'Here is where I need about a half second,
'or maybe quarter second delay.

counter = counter + 1
Loop

End Sub


worked on my machine. Can't say it waits exactly half a second, but there
is a measurable pause.

--
Regards,
Tom Ogilvy


"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









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Wait Seconds and Tenths

James, yours did work after Tom gave me the clue to how I could apply it. My
old brain just don't grasp things like it used to. I sort of have to be led
by the hand.

Happy hoidays! John

"Zone" wrote:

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









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Wait Seconds and Tenths

John, Terrific! Lets me know that it's not just a fluke that it's
working on my machine. Best regards for the new year, James
JLGWhiz wrote:
James, yours did work after Tom gave me the clue to how I could apply it. My
old brain just don't grasp things like it used to. I sort of have to be led
by the hand.

Happy hoidays! John

"Zone" wrote:

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










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
sendkeys(keys,wait) how do I use wait MM Excel Discussion (Misc queries) 1 February 11th 09 03:47 PM
Macro wait 30 seconds then Complete the Macro Vick Excel Discussion (Misc queries) 2 June 2nd 08 08:04 PM
Wait Seconds and Tenths Zone Excel Programming 0 December 23rd 06 04:46 PM
Display MsgBox wait for 10 seconds then click on yes automatically Vikram Dhemare Excel Programming 7 October 29th 06 11:57 AM
Average time for a race in minutes seconds & tenths Gammalite Excel Worksheet Functions 1 March 28th 06 03:50 AM


All times are GMT +1. The time now is 08:51 AM.

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"