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.

7 Comments

  1. Murray says:

    Nice program. But what about non-military time? AM/PM?

  2. Juan Pablo G says:

    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)

  3. Andy Miller says:

    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.

  4. Juan Pablo G says:

    Perhaps this ?

  5. Robert Svensson says:

    Very Cool :)

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

    Be Well
    Robert

  6. Tushar Mehta says:

    Inspired by the various clocks on the ‘Net I put together something different. See
    Floating clock
    http://www.tushar-mehta.com/excel/software/clocks/digital_clock.htm

  7. khabeer says:

    Nice trick……hide the grid lines….and it look awsome.

    Khabeer

Leave a Reply