CODE của mình như thế này:
Sub Auto_Run()
t1 = Format(Sheet1.Range("A1"), "hh:mm:ss")
t2 = Format(Sheet1.Range("A2"), "hh:mm:ss")
t3 = Format(Sheet1.Range("A3"), "hh:mm:ss")
t4 = Format(Sheet1.Range("A4"), "hh:mm:ss")
t5 = Format(Sheet1.Range("A5"), "hh:mm:ss")
t6 = Format(Sheet1.Range("A6"), "hh:mm:ss")
t7 = Format(Sheet1.Range("A7"), "hh:mm:ss")
t8 = Format(Sheet1.Range("A8"), "hh:mm:ss")
t9 = Format(Sheet1.Range("A9"), "hh:mm:ss")
t10 = Format(Sheet1.Range("A10"), "hh:mm:ss")
t11 = Format(Sheet1.Range("A11"), "hh:mm:ss")
t12 = Format(Sheet1.Range("A12"), "hh:mm:ss")
t13 = Format(Sheet1.Range("A13"), "hh:mm:ss")
t14 = Format(Sheet1.Range("A14"), "hh:mm:ss")
t15 = Format(Sheet1.Range("A15"), "hh:mm:ss")
t16 = Format(Sheet1.Range("A16"), "hh:mm:ss")
t17 = Format(Sheet1.Range("A17"), "hh:mm:ss")
t18 = Format(Sheet1.Range("A18"), "hh:mm:ss")
t19 = Format(Sheet1.Range("A19"), "hh:mm:ss")
t20 = Format(Sheet1.Range("A20"), "hh:mm:ss")
t21 = Format(Sheet1.Range("A21"), "hh:mm:ss")
t22 = Format(Sheet1.Range("A22"), "hh:mm:ss")
t23 = Format(Sheet1.Range("A23"), "hh:mm:ss")
t24 = Format(Sheet1.Range("A24"), "hh:mm:ss")
Application.OnTime t1, "updata"
Application.OnTime t2, "updata"
Application.OnTime t3, "updata"
Application.OnTime t4, "updata"
Application.OnTime t5, "updata"
Application.OnTime t6, "updata"
Application.OnTime t7, "updata"
Application.OnTime t8, "updata"
Application.OnTime t9, "updata"
Application.OnTime t10, "updata"
Application.OnTime t11, "updata"
Application.OnTime t12, "updata"
Application.OnTime t13, "updata"
Application.OnTime t14, "updata"
Application.OnTime t15, "updata"
Application.OnTime t16, "updata"
Application.OnTime t17, "updata"
Application.OnTime t18, "updata"
Application.OnTime t19, "updata"
Application.OnTime t20, "updata"
Application.OnTime t21, "updata"
Application.OnTime t22, "updata"
Application.OnTime t23, "updata"
Application.OnTime t24, "updata"
End sub
Sub updata()
fname = ThisWorkbook.Path & "\Stock board.xlsx"
sourcename = "Z:\Stboard\Data.xlsx"
timerr = Sheet1.Range("A1:C24").Value
On Error Resume Next
If Dir(sourcename) = "Data.xlsx" Then
For i = 1 To 24
For j = 1 To 3
If Format(timerr(i, j), "hh:mm:ss") = Format(Now, "hh:mm:ss") Then
With Application.Workbooks.Open(sourcename, 0)
arr = .Sheets("Data").Range("O51:Y81").Value
.Close False
End With
If IsFileOpen(fname) = False Then
Application.Workbooks.Open fname
Application.Workbooks("Stock board.xlsx").Sheets("Board").Range("O51").Resize(UBound(arr, 1), UBound(arr, 2)) = arr
Else
Application.Workbooks("Stock board.xlsx").Sheets("Board").Range("O51").Resize(UBound(arr, 1), UBound(arr, 2)) = arr
End If
Exit For
End If
Next j
Next i
End If
Auto_Run
Erase arr
End Sub
Không biết chạy lâu có gây ra lỗi không nhỉ?
Mình thử mấy cách như trong hướng dẫn mà không được