In this step-by-step video, we’ll show you how to utilize Visual Basic for Applications (VBA) to build a fully functional digital clock within Microsoft Excel.
—————————————————————————————————————————————————
Dim DigitalClock As Date
Sub MakingClock()
With Sheet1.Range(“C4”)
.Value = Format(Time, “hh:mm:ss AM/PM”)
End With
Call SetTime
End Sub
Sub SetTime()
DigitalClock = Now + TimeValue(“00:00:01”)
Application.OnTime DigitalClock, “MakingClock”
End Sub
Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=DigitalClock, Procedure:=”MakingClock”, Schedule:=False
End Sub
———————————————————————————————————————————————————