ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   continual updating (https://www.excelbanter.com/excel-programming/341476-continual-updating.html)

dok112[_43_]

continual updating
 

is there a way to have a caption update once every 1 minute? or every 5
minutes? My form is going to be keeping track of money that is being
spent, but I currently I have to click the update button when I want it
to update, where as if it auto-updates, it will save me some time...any
ideas???


--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=471815


Gareth[_7_]

continual updating
 
The below code, place in a standard code module should do the trick.
Replace the line "RefreshMyCaption" with whatever your refresh procedure
is named.

HTH,
Gareth

Private Constant SyncFreqInMinutes as integer = 1
Private myOnTime As Date

Sub SetAutoUpdate
'cancel any outstanding events - just in case
'it's not strictly necessary.
CancelAutoUpdate 'just in case

'work out when you want the next update to take place
myOnTime = Now + Timeserial(0,1,0)

'set the next update to take place
Application.OnTime myOnTime , "SetAutoUpdate"

'rename as to whatever the procedure is to drive the
'refresh
RefreshMyCaption

End Sub

Sub CancelAutoUpdate()
On Error Resume Next
Application.OnTime EarliestTime:=myOnTime , _
Procedu="SetAutoUpdate", _
Schedule:=False
End Sub

dok112 wrote:
is there a way to have a caption update once every 1 minute? or every 5
minutes? My form is going to be keeping track of money that is being
spent, but I currently I have to click the update button when I want it
to update, where as if it auto-updates, it will save me some time...any
ideas???



dok112[_44_]

continual updating
 

it works beautifully! THANKS!!


--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=471815


Gareth[_7_]

continual updating
 
You're welcome - thanks for letting me know.

Note that I just spotted I should have written:

'work out when you want the next update to take place
myOnTime = Now + Timeserial(0,SyncFreqInMinutes ,0)

rather than

'work out when you want the next update to take place
myOnTime = Now + Timeserial(0,1,0)

Of course it will still work the same - since SyncFreqInMinutes was set
as 1 anyway - but it you want to change the frequency to 2 or 3 minutes,
say, you just change the constant SyncFreqInMinutes to 2 or 3 etc. And
of course you could always change it to work with seconds.

G

dok112 wrote:
it works beautifully! THANKS!!




All times are GMT +1. The time now is 07:48 AM.

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