ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Continuous calculation of a formula. (https://www.excelbanter.com/excel-discussion-misc-queries/220611-continuous-calculation-formula.html)

Husker87

Continuous calculation of a formula.
 
I created a €śCountdown€ť clock to an event in our company. Just the actual
date minus todays date. Anyway, it just calculates days, hours, mins, secs
until an event. The problem is that you either have to hit F9 or some other
cell to get it to re-calculate the formulas. I set up a macro and tied it to
a €śrefresh€ť button but does anyone know how I could get the spreadsheet to
calculate every second automatically or perhaps another way to add a
€śCountdown clock€ť to my spreadsheet?
Thanks!


Gary''s Student

Continuous calculation of a formula.
 
Public whn As Double
Public Const T = 2 ' two seconds
Public Const macroo = "refresh" ' the name of the procedure to run

Sub refresh()
Application.CalculateFull
StartTimer
End Sub

Sub StartTimer()
whn = Now + TimeSerial(0, 0, T)
Application.OnTime EarliestTime:=whn, Procedu=macroo, Schedule:=True
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=whn, Procedu=macroo, Schedule:=False
End Sub

Run StartTimer to begin and StopTImer to end. The worksheet will be
re-calculated every two seconds.
--
Gary''s Student - gsnu200833


"Husker87" wrote:

I created a €śCountdown€ť clock to an event in our company. Just the actual
date minus todays date. Anyway, it just calculates days, hours, mins, secs
until an event. The problem is that you either have to hit F9 or some other
cell to get it to re-calculate the formulas. I set up a macro and tied it to
a €śrefresh€ť button but does anyone know how I could get the spreadsheet to
calculate every second automatically or perhaps another way to add a
€śCountdown clock€ť to my spreadsheet?
Thanks!



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

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