I have read a lot of questions, I have also taken advice on the Goggle the question and spent hours trying to get a simple timer
I tried using the Timer() feature but Debug does not like what I have . I called myself copying it correct I had even tried making a Dim Timer just in case.
Will anyone help me figure this out? Please See below tried to paste in the error message received and I read the help on it but still do not know what is wrong
is where is read?
Sub PauseCodeOld1() Dim Start As Single ' Snapshot of when timer started Dim Elapsed As Single ' Total time elapsed Dim Pausetime As Single ' Desired duration in seconds Dim TimerTemp As Single ' store current value of Timer function Dim Timer() As Single ' Added trying to stop the Subscript out of range (Error9) ' modified to as Single 081619 If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then Pausetime = 5 ' Set duration. 'MsgBox ("Time Now " & Results) ' Store current Timer value ' Timer is a VBA function that Returns a Single representing ' the number of seconds elapsed since midnight. Start = Timer() Do ' Begin a Do While Loop DoEvents ' Yield to other processes and waste time. ' Calculate elapsed time ' Get current value of Timer function TimerTemp = Timer ' Calculate how many seconds have elapsed between now and Start Elapsed = TimerTemp - Start Debug.Print "Elapsed: " & CStr(Elapsed) ' Determine if the Elapsed time is greater than desired pause time ' If not, then repeat loop Loop While Elapsed <= Pausetime MsgBox "Paused for " & CStr(Elapsed) & " seconds" End IfEnd Sub
This was the error, not sure if you can ready what is says Compile Error: Type Mismatch