PDA

View Full Version : On time assistance required



kaptanylmz
04-12-2020, 09:08 AM
Is there anyone can help my problem? I am new on VBA and made one code to copy my RTD cells to other sheet. The codes which I wrote is below,

qte///

Worksheets("Sayfa7").Range("A1:G14").Value = Worksheets("Sayfa6").Range("A1:G14").Value

unqte///


I wanted to copy cells with 10 seconds interval from 18:00:00 to 18:00:05.

I try to use with application.ontime but I didnot get success.

I need immediate help

Thanks for Reply...

Logit
04-13-2020, 02:09 PM
.
This will copy every 10 seconds :


Sub ScheduleCopyRng() TimeToRun = Now + TimeValue("00:00:10")
Application.OnTime TimeToRun, "CopyRng"
End Sub


Sub CopyRng()
Worksheets("Sayfa7").Range("A1:G14").Value = Worksheets("Sayfa6").Range("A1:G14").Value
Call ScheduleCopyRng
End Sub


Sub auto_close()
On Error Resume Next
Application.OnTime TimeToRun, "CopyRng", , False
End Sub

paulked
04-13-2020, 03:07 PM
You'll need to declare TimeToRun as a variable for the module, as in:



Private TimeToRun as Date

Sub ScheduleCopyRng()
TimeToRun = Now + TimeValue("00:00:10")
Application.OnTime TimeToRun, "CopyRng"
End Sub


etc...