Digital Clock

My buddy Juan was inspired by my Pixilation post and created a digital clock in Excel. He graciously sent it to me an allowed me to post it. I made a few minor changes to it, so if it’s broken, don’t blame Juan. Download it here:

XLDigiClock.zip

Here’s a sample of what’s in there.

Private Sub ShowClock()
Dim T As Single
Dim OldTime As Single

With Range("a1")
.Resize(11, 39).Interior.ColorIndex = xlNone
.Range("M3:M4,M8:M9,AA3:AA4,AA8:AA9").Interior.Color = vbRed

Do
OldTime = T
T = Time()

If Hour(T) > Hour(OldTime) Then Update jpHour, .Item(1), T
If Minute(T) > Minute(OldTime) Then Update jpMinute, .Item(1, 15), T
Update jpSecond, .Item(1, 29), T

Application.Wait Now + TimeSerial(0, 0, 1)
DoEvents
Loop Until bStop
End With

End Sub

Check out the rest of the code. There’s a great example of using enums in there. I think I need to add some code to change the cursor – even though it’s the hourglass, you can still click on the Stop button.

13 thoughts on “Digital Clock

  1. Murray, change this line in the ‘Update’ sub from

    Txt = Mid$(Format$(Time, “hh:mm:ss”), Item, 2)

    to

    Txt = Mid$(Format$(Time, “hh:mm:ss AM/PM”), Item, 2)

  2. I have a file in which someone made a pretty slick-looking Analog Clock in Excel (complete with moving second hand, minute hand, and hour hand).

    Unfortunately, the person didn’t sign it and I don’t remember where I got it in the first place. I can e-mail it to you if you’d like to see it. It’s really pretty interesting.

  3. Very Cool :)

    I am doing an XL clock and were browsing for ideas, I found your. I like it

    Be Well
    Robert

  4. Please any one can help me to have a formula to create digital live clock on a spread sheet?
    But, remember with out using VB codes OR MACRO I need to create a clock by using only excel formulas with any magical tricks.
    Will any Excel Guru can help me? Please email solution to nilantquest@yahoo.com
    Thanks in advance
    Nilantha

  5. Thnx Michael !
    I know this function, but it don’t update the time automatically/lively unless we click on it OR do any calculation in each minute. What I really want is to have a function to create live/automatically updating digital clock.
    Anyway thank you so much for the attention on my request.
    Nilantha

Leave a Reply

Your email address will not be published. Required fields are marked *