Forum Discussion

wbrock1302gmailcom's avatar
wbrock1302gmailcom
Copper Contributor
Jul 26, 2026

TIME FUNCTION

HOW DO YOU GET TIME TO ADVANCE AUTOMATICALLY

2 Replies

  • NikolinoDE's avatar
    NikolinoDE
    Platinum Contributor

    Alternatively, you could use VBA.

    This version:

    • updates every second,
    • stops cleanly when closing the workbook,
    • avoids duplicate timers if you accidentally run StartClock twice.

    Standard Module (Insert → Module):

    Option Explicit
    
    Dim NextTime As Date
    Dim ClockRunning As Boolean
    
    Sub StartClock()
    
        If ClockRunning = True Then Exit Sub
        
        ClockRunning = True
        
        UpdateClock
    
    End Sub
    
    
    Sub UpdateClock()
    
        If ClockRunning = False Then Exit Sub
    
        Range("A1").Value = Time
        Range("A1").NumberFormat = "hh:mm:ss"
    
        NextTime = Now + TimeValue("00:00:01")
        Application.OnTime NextTime, "UpdateClock"
    
    End Sub
    
    
    Sub StopClock()
    
        On Error Resume Next
        
        ClockRunning = False
        
        Application.OnTime NextTime, "UpdateClock", , False
    
    End Sub

    Optional: automatically stop when closing Excel

    In ThisWorkbook (not Module):

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
        StopClock
    
    End Sub

    OR...simply as Formula: =NOW()

    My answers are voluntary and without guarantee!

     

    Hope this will help you.

  • m_tarler's avatar
    m_tarler
    Silver Contributor

    more information about what you are trying to do would help.

    most likely you want to have a column of time and they a formula to show the output for all those time values but had to get into any specifics without more information.

    try sharing a sheet/workbook (if not here, put in an online site like onedrive or google or dropbox and share a link to it)

    post sample data / tables or at least images

    please do not share any confidential or private information (e.g. replace real names/ids/phone#/etc with fake info)