当时机成熟时,我收到错误声称宏无法在我的工作簿中运行。它已启用宏,我尝试保存新的。
我的代码
Option Explicit
Private Sub Workbook_Open()
Call ScheduleTask
End Sub
Public Sub ScheduleTask()
Application.OnTime TimeValue("11:42:30"), "pl1.Execute"
End Sub
Public Sub Execute()
Debug.Print "Executing task", Now
Dim lastrow As Long
lastrow = Sheets("Data").Range("H2").End(xlUp).Row + 1
Sheets("Data").Range("M2:M301").Copy
Sheets("Data").Range("H" & lastrow).PasteSpecial xlPasteValues
Call ScheduleTask
End Sub