+ Reply to Thread
Results 1 to 3 of 3

Wait time variable

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Wait time variable

    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")

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    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

  3. #3
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    Thanks Leith!! Works Great!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1