PC Review


Reply
Thread Tools Rate Thread

Automatic increment of onTime

 
 
Rob
Guest
Posts: n/a
 
      28th Feb 2010
Hi,
Please will someone tell me (if possible) how to automatically increment the
times in the following example. I have got 370 times to enter in one minute
increments.

Sub StartTime()
Application.OnTime TimeValue("17:28:00"), "CopyVolume1"
Application.OnTime TimeValue("17:29:00"), "CopyVolume2"
Application.OnTime TimeValue("17:30:00"), "CopyVolume3"
End Sub

Thanks.
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      28th Feb 2010
Hi Rob,

I have assumed that your start time is 17:28:00 so I have changed the
minutes to 27 to allow the first iteration to add 1 to become 28.

Also note that a space and underscore at the end of a line is a line break
in an other wise single line of code.

Dim i As Long

For i = 1 To 370
Application.OnTime _
TimeValue("17:" & 27 + i & ":00"), _
"CopyVolume" & i
Next i

--
Regards,

OssieMac


"Rob" wrote:

> Hi,
> Please will someone tell me (if possible) how to automatically increment the
> times in the following example. I have got 370 times to enter in one minute
> increments.
>
> Sub StartTime()
> Application.OnTime TimeValue("17:28:00"), "CopyVolume1"
> Application.OnTime TimeValue("17:29:00"), "CopyVolume2"
> Application.OnTime TimeValue("17:30:00"), "CopyVolume3"
> End Sub
>
> Thanks.

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      28th Feb 2010
Hi again Rob,

Disregard that answer; it won't work after 59 mins. I will have another look
at it.

--
Regards,

OssieMac


"Rob" wrote:

> Hi,
> Please will someone tell me (if possible) how to automatically increment the
> times in the following example. I have got 370 times to enter in one minute
> increments.
>
> Sub StartTime()
> Application.OnTime TimeValue("17:28:00"), "CopyVolume1"
> Application.OnTime TimeValue("17:29:00"), "CopyVolume2"
> Application.OnTime TimeValue("17:30:00"), "CopyVolume3"
> End Sub
>
> Thanks.

 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      28th Feb 2010
Hi yet again Rob,

My apologies for the previous version. Was not thinking clearly. The
following method of including the date should handle going past midnight
also. However, the code is untested in conjunction with the OnTime function.
Start time can be real first time because not incremented until after first
iteration.

Sub test()

Dim i As Long
Dim timeStart As Date
Dim timeIncrement As Date

timeStart = Date + TimeValue("17:28:00")
timeIncrement = TimeValue("00:01:00")

For i = 1 To 370
Application.OnTime timeStart, "CopyVolume" & i
timeStart = timeStart + timeIncrement
Next i

End Sub

--
Regards,

OssieMac


 
Reply With Quote
 
Rob
Guest
Posts: n/a
 
      1st Mar 2010
Thanks OssieMac.

"OssieMac" wrote:

> Hi yet again Rob,
>
> My apologies for the previous version. Was not thinking clearly. The
> following method of including the date should handle going past midnight
> also. However, the code is untested in conjunction with the OnTime function.
> Start time can be real first time because not incremented until after first
> iteration.
>
> Sub test()
>
> Dim i As Long
> Dim timeStart As Date
> Dim timeIncrement As Date
>
> timeStart = Date + TimeValue("17:28:00")
> timeIncrement = TimeValue("00:01:00")
>
> For i = 1 To 370
> Application.OnTime timeStart, "CopyVolume" & i
> timeStart = timeStart + timeIncrement
> Next i
>
> End Sub
>
> --
> Regards,
>
> OssieMac
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic increment of Invoice number Andreas Microsoft Access Forms 3 20th Jan 2007 01:01 PM
stop automatic increment of dates =?Utf-8?B?U3VzYW4gQy4=?= Microsoft Excel Misc 2 21st Sep 2005 05:57 PM
automatic increment Çinko Microsoft VB .NET 2 11th Oct 2004 02:05 PM
Automatic increment an Microsoft Access Forms 8 2nd Mar 2004 09:10 AM
automatic counter or auto-increment =?Utf-8?B?Smp0?= Microsoft Excel Programming 1 16th Jan 2004 07:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:10 PM.