將程序複製到ThisWorkbook 模組 存檔後
重新開啟一次檔案即可
Private Sub Workbook_Open()
Application.OnTime TimeValue("09:00"), "thisworkbook.mywork"
End Sub
Private Sub MyWork()
If Weekday(Date, 2) < 6 Then
With Sheet2.[A65536].End(xlUp).Offset(1)
.Value = Date
.Offset(, 1).Resize(, 3) = Sheet1.[A1].Resize(, 3).Value
End With
End If
Application.OnTime TimeValue("09:00"), "thisworkbook.mywork"
End Sub作者: victorl 時間: 2010-6-4 08:34
【個人經驗】因有可能9:00事件觸發時,同時開了多個Excel files & Activeworkbook並不是此欲執行的檔案而導致執行錯誤問題,因此在Private Sub MyWork()
開始處加一判斷式並指定Activeworkbook就可避免執行錯誤問題了。
For Each wb In Workbooks
If InStr(wb.Name, "*****") > 0 Then '*****->Excel檔名
wb.Activate
.
.
.
End If
Next