ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I calculate at timed intervals? (https://www.excelbanter.com/excel-programming/396139-how-do-i-calculate-timed-intervals.html)

qaf

How do I calculate at timed intervals?
 
I want to perform calculations at timed intervals. I wrote the
following macro:

Public Function CalcNow(CurTime As Date) As Boolean
Static bInitialized As Boolean
Static StartTime As Date, EndTime As Date
Dim TimeDiff As Double

If Not bInitialized Then
StartTime = Now()
EndTime = Now()
bInitialized = True
End If
EndTime = Now()
TimeDiff = (EndTime - StartTime) * 86400
If TimeDiff 5 Then
Application.Calculate
StartTime = Now()
End If
End Function

The current time is in cell A1 and I pass that value to trigger the
running of the function every second - BUT since I am in manual
calculation mode, cell A1 does not update - UGH!!

Any suggestions are appreciated.

Gary Brown

How do I calculate at timed intervals?
 
forget about the CurrTime.
Make the Function a Sub and run it.
--
HTH,
Gary Brown

If this post was helpful to you, please select
''''''''''''''''YES'''''''''''''''' at the bottom of the post.



"qaf" wrote:

I want to perform calculations at timed intervals. I wrote the
following macro:

Public Function CalcNow(CurTime As Date) As Boolean
Static bInitialized As Boolean
Static StartTime As Date, EndTime As Date
Dim TimeDiff As Double

If Not bInitialized Then
StartTime = Now()
EndTime = Now()
bInitialized = True
End If
EndTime = Now()
TimeDiff = (EndTime - StartTime) * 86400
If TimeDiff 5 Then
Application.Calculate
StartTime = Now()
End If
End Function

The current time is in cell A1 and I pass that value to trigger the
running of the function every second - BUT since I am in manual
calculation mode, cell A1 does not update - UGH!!

Any suggestions are appreciated.



All times are GMT +1. The time now is 10:45 PM.

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