Sub 每分迴圈()
xTime = TimeSerial(Hour(Time), Minute(Time) + 1, 0)
Application.OnTime xTime, "每分執行"
With ThisWorkbook.Worksheets("工作表1")
.Cells(1, 1) = .Cells(1, 1) + 1
End With
End Sub
Sub 停止執行()
Application.EnableCancelKey = xlInterrupt
End Sub作者: faye59 時間: 2018-9-6 22:22
Sub 每分迴圈()
xTime = TimeSerial(Hour(Time), Minute(Time) + 1, 0)
Application.OnTime xTime, "每分迴圈"
With ThisWorkbook.Worksheets("工作表1")
.Cells(1, 1) = .Cells(1, 1) + 1
End With
End Sub
Sub 停止執行()
On Error Resume Next '(略過錯誤) 若預訂執行的程式已不存在, 不發生錯誤
Application.OnTime xTime, "每分迴圈", Schedule:=False '取消預訂執行程序
On Error GoTo 0
End Sub