|
分享一個程式碼,不知道有沒有幫助,我不會寫程式
Private Sub Workbook_Open()
If Time >= TimeValue("09:00:00") And Time <= TimeValue("13:30:00") Then
Sheet1.[B12:E281] = "" '每天第一次開啟檔案時清除昨日資料
download
Else
Application.OnTime "09:01:00", "ThisWorkbook.download"
End If
End Sub
Private Sub download() '此程序與 Workbook_Open 同在 ThisWorkbook裡
Dim TimeRange As Range, Rng As Range, R As Range, i%
With Sheet1 '[A12:A281] 間必須已輸入 09:01 - 13:30 的時間
Set TimeRange = [A:A].Find(TimeSerial(Hour(Time), Minute(Time), "00"))
Set Rng = TimeRange.Offset(, 1).Resize(1, 4)
For Each R In .Range("D1,D3,F2,D5")
i = i + 1
Rng(i) = R
Next
End With
If Time > TimeValue("13:30:00") Then Exit Sub
Application.OnTime Now + TimeValue("00:01"), "ThisWorkbook.download"
End Sub
|
|