Thanks Kaiowas. I’ll have a play with it and see if I can adapt it. :cheers:
Should be easy to get it up and running, all you should really need to do is:
Copy the code into your workbook (there’s a module plus workbook_open and workbook_close events)
Find somewhere in your workbook to store the next update time value (the example uses cell A1)
Modify the code references to this cell to suit (2 in the update routine, 2 in wookbook_close) they should really use full Thisworkbook.Worksheets(“Sheetname”).Range(“A1”) type references to prevent problems caused by you potentially switching to another workbook or worksheet between updates.
Set your update period.
Kaiowas code is =
Sub AutoRefresh()
intRefreshPeriod = 1 'Time in seconds between refreshes
'Force Excel to recalculate
Application.Calculate
'Schedule next refresh event
strNextUpdateTime = ThisWorkbook.ActiveSheet.Range("A1")
If strNextUpdateTime <> "" Then 'Cancels scheduled future update should update period be modified
If strNextUpdateTime > Now Then Application.OnTime strNextUpdateTime, "AutoRefresh", , False
End If
strNextUpdateTime = Now + TimeValue(Format(intRefreshPeriod / 86400, "HH:MM:SS"))
ThisWorkbook.ActiveSheet.Range("A1") = strNextUpdateTime
If strNextUpdateTime <> "" Then Application.OnTime strNextUpdateTime, "AutoRefresh"
End Sub
Sub StopAutoRefresh()
strNextUpdateTime = ThisWorkbook.ActiveSheet.Range(“A1”)
Application.OnTime strNextUpdateTime, “AutoRefresh”, , False
ThisWorkbook.ActiveSheet.Range(“A1”) = “”
End Sub
Sometimes people will not download code xls/mdb/exe ----extracted from his XLS
Cheers for that guys. Been clearing out my sister’s house ready for her move, but I’ll try and play with it over the weekend. :cheers:
Had a play with it and after working out that the If Then statement places a time value in cell A1, it was causing a 1004 error due to the fact that that cell was protected and couldn’t be written to :rolleyes:. Unprotected that cell and ran it, all seems to be working OK. Thanks for all your help Kaiowas and for the assist Greg. This particular proggy works and it gives me something that I can use and adapt for other projects in the future!
Its good information you have provided here about page refresh. It will be helpful for everybody to data update.
The sheet is protected to prevent overtyping formulas, but no password input. The calculations are on hidden rows and columns, but not marked, so it’s a bit messy. I’ll tidy it up when I have time, but you can play with it if you want. Needs Excel 2003 or better.