#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Timer

Hi,

A cell displays the current date and time, which does not refresh if nothing
is done.

How can I arrange for the cell to be up-dated automatically at set intervals
e.g. every minute.

Don

--



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Timer

You would have to use a programmatic solution. Put the following in a
standard VBA module.

Option Explicit

Dim NextTime As Date
Sub RepeatOneSec()
Application.Calculate
NextTime = Now() + TimeSerial(0, 0, 1)
Application.OnTime NextTime, "RepeatOneSec"
End Sub
Sub EndProcess()
Application.OnTime NextTime, "RepeatOneSec", , False
End Sub

Change the TimeSerial() parameters to suit. Currently, it updates the
XL environment every second.

Once done, run the RepeatOneSec macro. Run the EndProcess macro to stop
the automatic updates.

--
Regards,

Tushar Mehta
MS MVP Excel 2000-2003
www.tushar-mehta.com
Excel, PowerPoint, and VBA tutorials and add-ins
Custom Productivity Solutions leveraging MS Office


In article ,
says...
Hi,

A cell displays the current date and time, which does not refresh if nothing
is done.

How can I arrange for the cell to be up-dated automatically at set intervals
e.g. every minute.

Don

--




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Timer

Thank you Tushar,

As expected, works fine.

Just one query.
If the routine is called on opening the workbook, is it necessary (or
advisable) to stop the timer before running other routines?

regards,
Don
--

"Tushar Mehta" wrote in message
om...
You would have to use a programmatic solution. Put the following in a
standard VBA module.

Option Explicit

Dim NextTime As Date
Sub RepeatOneSec()
Application.Calculate
NextTime = Now() + TimeSerial(0, 0, 1)
Application.OnTime NextTime, "RepeatOneSec"
End Sub
Sub EndProcess()
Application.OnTime NextTime, "RepeatOneSec", , False
End Sub

Change the TimeSerial() parameters to suit. Currently, it updates the
XL environment every second.

Once done, run the RepeatOneSec macro. Run the EndProcess macro to stop
the automatic updates.

--
Regards,

Tushar Mehta
MS MVP Excel 2000-2003
www.tushar-mehta.com
Excel, PowerPoint, and VBA tutorials and add-ins
Custom Productivity Solutions leveraging MS Office


In article ,
says...
Hi,

A cell displays the current date and time, which does not refresh if

nothing
is done.

How can I arrange for the cell to be up-dated automatically at set

intervals
e.g. every minute.

Don

--






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TIMER Jase Excel Discussion (Misc queries) 1 September 8th 08 10:22 PM
timer Steve[_9_] Excel Discussion (Misc queries) 4 January 28th 08 08:10 PM
Timer in VBA peyman Excel Discussion (Misc queries) 2 October 5th 07 06:53 PM
Lap-timer kabildgaard Excel Discussion (Misc queries) 0 August 11th 06 03:26 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM


All times are GMT +1. The time now is 03:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"