How to make a real time clock in Excel? A Step by Step Guide

Excel is not just for spreadsheets it can also display dynamic elements like a real-time clock! In this guide, we’ll show you how to create a clock that updates automatically in Excel.

Step 1: Open a New Excel Worksheet

blank spreadsheet

Step 2: Set Up the Layout

  • Decide where you want your clock to appear.
  • For a simple clock, you can dedicate a single cell (e.g., A3) to display the current time.

Step 3: Use the NOW() Function

In the chosen cell, enter the formula:

=NOW()  This will display the current date and time

Step 4: Format the Cell to Show Only the Time

 

  • To display only the time:
    1. Right-click on the cell with the formula.
    2. Select Format Cells.
    3. Choose the Custom category.
    4. Enter the format hh:mm:ss AM/PM for a 12-hour clock or HH:mm:ss for a 24-hour clock.
    5. Click OK.

excel format cell option

 

Step 5: Enable Automatic Updates

 

You’ll need to enable VBA (Visual Basic for Applications) to create a real-time clock, VBA has been placed in the edeveloper tab.

Step 6: Enable Developer Tab

 

If the Developer tab is not visible:

  • Go to File > Options > Customize Ribbon.
  • Choose the commands from popular commands to Main tabs (this option may vary with the different versions of excel)
  • Check the box for Developer under Main Tabs.
  • Click OK.

 

how to enable the developer tab in excel

 

 

Step 7: Write a VBA Script for Real-Time Updates

 

  1. Open the VBA editor:
  2. Go to the Developer tab and click on Visual Basic, first option in top left side.

  1. Create a new module:
    • In the VBA editor, click Insert > Module.

  • Paste the following code:

Dim RunWhen As Double
Dim TimerInterval As Double

Sub StartClock()
TimerInterval = Now + TimeValue(“00:00:01″)
Application.OnTime EarliestTime:=TimerInterval, Procedure:=”ShowTime”, Schedule:=True
End Sub

Sub ShowTime()
Range(“A3”).Value = Format(Now, “hh:mm:ss AM/PM”)
StartClock
End Sub

Sub StopClock()
On Error Resume Next
Application.OnTime EarliestTime:=TimerInterval, Procedure:=”ShowTime”, Schedule:=False
End Sub

8.Close the VBA editor and save the workbook as a Macro-Enabled Workbook (.xlsm).

After saving the document you can run the vb code using the macro option

Run the Macro:

  • Go to the Developer tab and click Macros in the Code group.
  • In the Macro dialog box:
    1. Select the macro you want to run from the list.
    2. Click Run.

The real-time clock in Excel will run automatically based on your computer time zone.

Know More Visit : 

Leave a Comment

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