Mình có 1 file VBA chạy đồng hồ nhưng trên đấy nó hiện cả ngày tháng lên nữa. Mình muốn nó chỉ chạy mỗi đồng hồ thôi thì làm thế nào? Mình copy VBA đấy vao đây anh em xem giúp nhé.
Option Explicit
Const DateAndTimeCell As String = "B9"
Dim OK As Boolean
Sub StartUpdate()
Range(DateAndTimeCell).NumberFormat = "dd.mm.yyyy hh:mm:ss"
OK = True
Update
End Sub
Sub Update()
Dim StatBarMsgString As String
If OK Then
Range(DateAndTimeCell).Formula = Now
Application.StatusBar = StatBarMsgString & Format(Now, "d.m.yyyy hh:mm:ss")
Application.OnTime Now + TimeValue("00:00:01"), "Update", , True
Else
Range(DateAndTimeCell).Formula = ""
Application.StatusBar = False
End If
End Sub
Sub StopUpdate()
OK = False
Update
Range(DateAndTimeCell).NumberFormat = "general"
End Sub
Anh em nào biết thì sửa vào đây luôn nhé. Cảm ơn nha.
Option Explicit
Const DateAndTimeCell As String = "B9"
Dim OK As Boolean
Sub StartUpdate()
Range(DateAndTimeCell).NumberFormat = "dd.mm.yyyy hh:mm:ss"
OK = True
Update
End Sub
Sub Update()
Dim StatBarMsgString As String
If OK Then
Range(DateAndTimeCell).Formula = Now
Application.StatusBar = StatBarMsgString & Format(Now, "d.m.yyyy hh:mm:ss")
Application.OnTime Now + TimeValue("00:00:01"), "Update", , True
Else
Range(DateAndTimeCell).Formula = ""
Application.StatusBar = False
End If
End Sub
Sub StopUpdate()
OK = False
Update
Range(DateAndTimeCell).NumberFormat = "general"
End Sub
Anh em nào biết thì sửa vào đây luôn nhé. Cảm ơn nha.