Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to substitue the following:
Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
The following example might help. A lot of the code could be placed in one line of code but I separated the steps and included comments to help you understand it more easily. I assumed that the value in C9 is a simple number like 5 to represent 5 seconds. Is this assumption correct? If not then might have to re-look at the code. If you copy the code into a blank workbook and place a button from the Forms Toolbar (not the Controls Toolbar) on a worksheet to run the code then you can watch the values change in cells A1 and A2. Feel free to get back to me if not what you need. Sub TimeWaitTest() Dim dblWaitTime As Double Dim strWaitTime As String Dim timeWaitTime As Date 'Note time variable is actually a date Dim timeFinish As Date 'Format cells A1 and A2 to time Range("A1:A2").NumberFormat = "hh:mm:ss" 'Following converts seconds entered as a number _ to a fraction of a day dblWaitTime = Worksheets("Tables").Range("C9") / 24 / 60 / 60 'Following converts fraction of a day to a string _ that is formatted as time strWaitTime = Format(dblWaitTime, "h:m:s") 'Convert string to time value timeWaitTime = TimeValue(strWaitTime) 'Save the time to finish timeFinish = Now() + timeWaitTime Range("A1") = timeFinish Do While Now() <= timeFinish Range("A2") = Now() Loop End Sub -- Regards, OssieMac "Tom Joseph" wrote: I am trying to substitue the following: Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi agaion Tom,
You better discard that answer. I realize I was off in fairy land. You want Wait not what I have given you. will have another look at it. -- Regards, OssieMac "Tom Joseph" wrote: I am trying to substitue the following: Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Tom,
Try this one instead. Sub TimeWaitTest2() Dim dblWaitTime As Double Dim strWaitTime As String Dim timeWaitTime As Date 'Note time variable is actually a date Dim timeFinish As Date 'Format cells A1 and A2 to time Range("A1:A2").NumberFormat = "hh:mm:ss" 'Following converts seconds entered as a number _ to a fraction of a day dblWaitTime = Worksheets("Tables").Range("C9") / 24 / 60 / 60 'Following converts fraction of a day to a string _ that is formatted as time strWaitTime = Format(dblWaitTime, "h:m:s") 'Convert string to time value timeWaitTime = TimeValue(strWaitTime) Range("A1") = Now() Application.Wait Now() + timeWaitTime Range("A2") = Now() -- Regards, OssieMac |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am definitely off in fairy land today Tom. My apologies for that. You don't
need all of my last answer either just the following. Sub TimeWaitTest3() Dim dblWaitTime As Double Dim timeFinish As Date 'Format cells A1 and A2 to time Range("A1:A2").NumberFormat = "hh:mm:ss" 'Following converts seconds entered as a number _ to a fraction of a day dblWaitTime = Worksheets("Tables").Range("C9") / 24 / 60 / 60 Range("A1") = Now() Application.Wait Now() + dblWaitTime Range("A2") = Now() End Sub -- Regards, OssieMac "Tom Joseph" wrote: I am trying to substitue the following: Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I greatly appreciate the help on this. I will give it a try.
Best, Tom "OssieMac" wrote: I am definitely off in fairy land today Tom. My apologies for that. You don't need all of my last answer either just the following. Sub TimeWaitTest3() Dim dblWaitTime As Double Dim timeFinish As Date 'Format cells A1 and A2 to time Range("A1:A2").NumberFormat = "hh:mm:ss" 'Following converts seconds entered as a number _ to a fraction of a day dblWaitTime = Worksheets("Tables").Range("C9") / 24 / 60 / 60 Range("A1") = Now() Application.Wait Now() + dblWaitTime Range("A2") = Now() End Sub -- Regards, OssieMac "Tom Joseph" wrote: I am trying to substitue the following: Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
application.wait now + timeserial(0,0,Worksheets("Tables").Range("C9").va lue)
You may want to add a check to see if that value makes sense. Tom Joseph wrote: I am trying to substitue the following: Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Dave.
I appreciate the help. "Dave Peterson" wrote: application.wait now + timeserial(0,0,Worksheets("Tables").Range("C9").va lue) You may want to add a check to see if that value makes sense. Tom Joseph wrote: I am trying to substitue the following: Application.Wait Now + TimeValue("0:0:5") With a TimeValue that uses a cell value as the number of seconds, for example from Worksheets("Tables").Range("C9") Can someone please help with the proper syntax format? Thanks, -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
wait msgbox for 3 seconds only | Excel Programming | |||
Macro wait 30 seconds then Complete the Macro | Excel Discussion (Misc queries) | |||
Wait Seconds and Tenths | Excel Programming | |||
Wait Seconds and Tenths | Excel Programming | |||
Display MsgBox wait for 10 seconds then click on yes automatically | Excel Programming |