You may need to use DoEvents() in your routine.
Here is an API timer and two examples using the Timer routine in Excel similar to AlphaFrog's routine. You will need to add the class if you want to try that method.
Sub Test_Timer()
'http://stackoverflow.com/questions/198409/how-do-you-test-running-time-of-vba-code
Dim t As New cTimer
t.StartCounter
Application.Wait Now + TimeValue("00:00:05")
MsgBox t.TimeElapsed / 1000 & " seconds."
Dim d As Double
d = Timer
Application.Wait Now + TimeValue("00:00:05")
MsgBox Timer - d & " seconds."
End Sub
Sub Test_TimersHelp()
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If
End Sub
Bookmarks