ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with WAIT (https://www.excelbanter.com/excel-programming/275714-problem-wait.html)

Mike[_46_]

Problem with WAIT
 
Hi,
I’m having a problem displaying seconds as they count down
from a value.

Help indicates the following code for the WAIT method:

This example displays a message indicating whether 10
seconds have passed.
If Application.Wait(Now + TimeValue("0:00:10")) Then
MsgBox "Time expired"
End If

When I put the example in my code as a stand-alone, it
works as advertised. So, based on above, I’ve written the
following code:

For i = 10 To 1 Step -1
If Application.Wait(Now + TimeValue("0:00:01")) Then
Range(A1).Offset(2, 0).Value = i
Next i

The problem is that I get an error saying ‘For’ without
a ‘Next’. If I comment out the “If Application...” line,
the Next is found and it runs! (Of course I get a “1” in
the cell, but that is expected.)

What I really want to do is, based on a count value in a
cell (1-99) display a count-down in another cell. The
count should increment in seconds. I don’t care if the
application is stopped for 1-second intervals or not. The
key here is showing the counting down.

I’m using Excel 2000 if it makes a difference.

Any ideas? Thanks in advance.
Mike



All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com