Application.OnTime Now + TimeValue("00:00:05"), "ThisWorkBook.ExeSelf"
End Sub
Private Sub ExeSelf()
On Error Resume Next
i = i + 1
If i = 1 Then
Sheets(1).Cells(1, 1) = Date
i = i + 1
End If
Sheets(1).Cells(i, 2) = Time
Sheets(1).Cells(i, 3) = Sheets(2).Cells(2, 1)
Sheets(1).Cells(i, 4) = Sheets(2).Cells(2, 2)
Sheets(1).Cells(i, 5) = Sheets(2).Cells(2, 3)
Application.OnTime Now + TimeValue("00:00:05"), "ThisWorkBook.ExeSelf"
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:05"), "ThisWorkBook.ExeSelf", , False
End Sub
Private Sub Workbook_Open()
Sheet2.[B7:J307] = ""
If Time >= TimeValue("08:45:00") And Time <= TimeValue("13:45:00") Then
change
Else
Application.OnTime "08:45:00", "ThisWorkbook.change"
End If
End Sub
Private Sub change()
Dim TimeRange As Range, Rng As Range, R As Range
With Sheet2
Set TimeRange = .[A:A].Find(TimeSerial(Hour(Time), Minute(Time), 0), LookIn:=xlFormulas)
Set Rng = TimeRange.Offset(, 1).Resize(1, 7)
End With
Rng.Value = Sheet1.[N3:T3].Value
If Time > TimeValue("13:45:00") Then Exit Sub
Application.OnTime Now + TimeValue("00:01"), "ThisWorkbook.change"
End Sub
If Time >= TimeValue("09:45:00") And Time <= TimeValue("16:05:00") Then
Sheet2.[B7:J307] = ""
change
Else
Application.OnTime "09:45:00", "ThisWorkbook.change"
End If
End Sub
Private Sub change()
Dim TimeRange As Range, Rng As Range, R As Range
With Sheet2
Set TimeRange = .[A:A].Find(TimeSerial(Hour(Time), Minute(Time), 0), LookIn:=xlFormulas)
Set Rng = TimeRange.Offset(, 1).Resize(1, 7)
End With
Rng.Value = Sheet1.[N3:T3].Value
If Time > TimeValue("16:05:00") Then Exit Sub
Application.OnTime Now + TimeValue("00:01"), "ThisWorkbook.change"
End Sub