Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Function Now and automatic Updating

Status
Not open for further replies.

campbemr

Technical User
Aug 16, 2001
19
US
In one section of my spreadsheet I want to calculate the elapsed time. So I have a formula like
=Now() - $B$12
where $B$12 has the start date

I do not know if Now() would be the correct function in this instance or not. Because the way that it is working it will calculate whenever the cell B12 is changed and I don't want that. I want the cell to change with every minute elapsed. Is there some way that this cell can be formatted to do this or do I have to write a macro. And if so what event may I have to use.
 
You could use the OnTime VBA method, as follows
Code:
Sub UpdateTimer()
    [Duration] = Now() - [StartTime]
    Application.OnTime Now + _
        TimeValue("0:01:00"), "UpdateTimer"
End Sub
where StartTime is the cell that holds the start date/time and duration is the cell you wish to update every minute.

The procedure schedules itself to update every minute.

A.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top