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.

12 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

  8. Nilantha says:

    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

  9. Michael says:

    Nilantha -

    Look at the NOW() function. Format your cell to your desired time style.

    …mrt

  10. Nilantha says:

    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

  11. Michael says:

    Nilantha -

    Sorry, but by not allowing VBA, NOW() is as close as you can get.

    …mrt

  12. Billy says:

    I have Excel 2007 and I cant find the “Update” button you were talking about. Can you help me?

Leave a Reply