Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Wait with TimeValue using the seconds from a worksheet cell

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Wait with TimeValue using the seconds from a worksheet cell

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
wait msgbox for 3 seconds only Eddy Stan Excel Programming 2 November 26th 08 06:58 PM
Macro wait 30 seconds then Complete the Macro Vick Excel Discussion (Misc queries) 2 June 2nd 08 08:04 PM
Wait Seconds and Tenths Chip Pearson Excel Programming 7 December 26th 06 02:12 PM
Wait Seconds and Tenths Zone Excel Programming 0 December 23rd 06 04:46 PM
Display MsgBox wait for 10 seconds then click on yes automatically Vikram Dhemare Excel Programming 7 October 29th 06 11:57 AM


All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"