Wait time variable

  • Thread starter Thread starter Brian Matlack
  • Start date Start date
B

Brian Matlack

Hi!
In the code listed below, how can I make the Time Value refer to a cell
on the worksheet?
Thanks
Application.Wait Format(Now + TimeValue("00:00:01"), "hh:mm:ss")
 
Hello Brian,

EXAMPLE:
Place your time delay in seconds in cell $A$1 of the Active Worksheet.
This example uses 1 second.

$A$1 = 1
Application.Wait (Now + TimeSerial(0, 0, Range("$A$1").Value)

To access a $A$1 (or any cell you choose) on another Worksheet...
Application.Wait (Now + TimeSerial(0, 0,
Worksheets("Sheet2").Range("$A$1").Value)

The advantages TimeSerail has over TimeValue are TimeSerial will still
yield the correct time if there is an overflow in a placeholder and it
doesn't require formating the cell as a String.

If n = 62 or 62 seconds, TimeSerial(0, 0, n) will convert correctly to
1 minute and 2 seconds. Setting TimeValue with seconds greater than 59
generates an error. So, TimeValue("00:00:" & n) won't work.

Sincerely,
Leith Ross
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top