Thread: time delay
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Incidental Incidental is offline
external usenet poster
 
Posts: 226
Default time delay

Hi back again, was feeling bad about not reading your post correctly
the first time round. I had a search through the groups and have come
up with this, which probably won't solve your problem but it may help
you figure out what to do...

After trying a few different methods I came across a snippet posted by
Ray McCoppin back in April of this year, which is a fantastic little
bit of code that I shall be keeping in mind myself.

I couldn't get this to work on a userform but it seems to work just
fine on a worksheet.

Create a userform with a command button on it then add this code

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub CommandButton1_Click()
[A2] = Time 'show start time
Call sleepy
End Sub

Private Sub Add1()
[A1] = [A1] + 1
If [A1] = 100 Then
[A3] = Time 'show finish time
Exit Sub
Else
Call sleepy
End If
End Sub

Private Sub UserForm_Initialize()
[A1] = 1 'number to start count
End Sub

Private Sub sleepy()
Sleep 500 'set amount of milliseconds delay here
Call Add1
End Sub

By my count if you count 1 to 100 with a half second between each count
it should take you 50 seconds (shouldn't it?? LoL) well this will do
just that.

I hope it helps you out and again I'm sorry for not reading your post
properly the first time round.

S