ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to make sheet continuosly re-calc (https://www.excelbanter.com/excel-programming/331509-how-make-sheet-continuosly-re-calc.html)

Robert Clarke

How to make sheet continuosly re-calc
 
Using a macro how can I make excel continously recalc to update the time
showing in a cell?
Thanks
Bob



Toppers

How to make sheet continuosly re-calc
 
Bob,
If you are going to recalculate your time ( using NOW? for eample)
what condition do you want to have to STOP the calculation.


"Robert Clarke" wrote:

Using a macro how can I make excel continously recalc to update the time
showing in a cell?
Thanks
Bob




keepITcool

How to make sheet continuosly re-calc
 
Bob,

'continously' has different meanings..
i supposed you meant regularly..

i'm not entirely convinced of the merits of a running clock in a
worksheet but here it goes..


''THISWORKBOOK
Option Explicit
Private Sub Workbook_Activate()
If Me.ActiveSheet Is Sheet1 Then startclock
End Sub
Private Sub Workbook_Deactivate()
If Me.ActiveSheet Is Sheet1 Then stopclock
End Sub

''SHEET1
Option Explicit
Private Sub Worksheet_Activate()
startclock
End Sub
Private Sub Worksheet_Deactivate()
stopclock
End Sub


''MODULEx:
Option Explicit
Private Declare Function KillTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function SetTimer Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Dim lngTimer As Long

Public Sub startclock()
the uElapse is set in Milliseconds!
lngTimer = SetTimer(0&, 0&, 1000&, AddressOf DoTimer)
End Sub

Public Sub stopclock()
KillTimer 0&, lngTimer
End Sub

Public Sub DoTimer()
Sheet1.Cells(1, 1) = Time
End Sub



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Toppers wrote :

Bob,
If you are going to recalculate your time ( using NOW? for
eample) what condition do you want to have to STOP the calculation.


"Robert Clarke" wrote:

Using a macro how can I make excel continously recalc to update the
time showing in a cell?
Thanks
Bob




keepITcool

How to make sheet continuosly re-calc
 

OOPS:

Important change if you want to avoid crashes...
(during editing or with modal dialogs)

Public Sub DoTimer()
ON ERROR RESUME NEXT
Sheet1.Cells(1, 1) = Time
End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam




Robert Clarke

How to make sheet continuosly re-calc
 
I want to stop with a button_click event.

Rob

"Toppers" wrote in message
...
Bob,
If you are going to recalculate your time ( using NOW? for

eample)
what condition do you want to have to STOP the calculation.


"Robert Clarke" wrote:

Using a macro how can I make excel continously recalc to update the time
showing in a cell?
Thanks
Bob







All times are GMT +1. The time now is 05:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com