BuffaloGuy
New Member
- Joined
- Dec 5, 2017
- Messages
- 28
Every minute, this code copies Cells C3:M3 on the Calculation worksheet, and pastes it in the first available row on the Data worksheet.
The problem is, it pastes the code four times in a matter of seconds. Is there a way to stop the loop after one occurrence?
The problem is, it pastes the code four times in a matter of seconds. Is there a way to stop the loop after one occurrence?
VBA Code:
Option Explicit
Dim TimeToRun
Sub MacroRun()
TimeToRun = Now + TimeValue("00:01:00")
Application.OnTime TimeToRun, "Macro1"
End Sub
Sub Macro1()
Calculate
ThisWorkbook.Worksheets("Calculation").Range("C3:M3").Copy
ThisWorkbook.Worksheets("Data").Cells(Rows.Count, "C").End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
MacroRun
End Sub
Sub stopMacros()
On Error Resume Next
Application.OnTime TimeToRun, "Macro1", , False
End Sub