Forum Discussion
Automatic Date Update (No Interaction)
We have a file I wish to have displayed on a TV 24/7 in which a counter shows how many days since an event last occurred. The only time interaction with the file would occur would be to update the last event date. Besides that, I am trying to have it where with the file remaining open and with no human interaction will still stay updated as to the current date. I tried making the date an external connection and setting the auto-refresh up on it, but it changes itself from a forumla to the last refresh cycle and locks there until changed again manually. Any thoughts or ideas?
6 Replies
- BennadeauIron Contributor
Hi ldcox8551,
Alternatively, you can add a clock in your spreadsheet with a macro. This will write the current date in cell A1 and current date in cell A2. Since it refresh every second, your spreadsheet will recalculate every second. Execute "SetTime" to start the process and "Disable" to stop the process.
Dim SchedRecalc As Date
Sub Recalc()
With Sheet1.Range("A1")
.Value = Format(Date)
End With
With Sheet1.Range("A2")
.Value = Format(Time, "hh:mm:ss AM/PM")
End With
Call SetTime
End Sub
Sub SetTime()
SchedRecalc = Now + TimeValue("00:00:01")
Application.OnTime SchedRecalc, "Recalc"
End Sub
Sub Disable()
On Error Resume Next
Application.OnTime EarliestTime:=SchedRecalc, Procedure:="Recalc", Schedule:=False
End Sub
P.S. I copied this macro from another source.
- Craig HatmakerIron Contributor
Any data source can be set to auto-refresh and almost all data sources have a system time function that can be returned to Excel using MS Query or PowerQuery. Here is the PQ example:
- In Excel use menu option: Data > New Query > From other sources > Blank Query
- In PQ use menu option Advanced Editor and make this edit
let
Source = DateTime.LocalNow
in
Source - Click Done
- Click Invoke
- Click File > Close & Load
- In Excel click Table Tools Design > Properties
- Click small icon (connection properties) next to Name:
- Check Refresh Every and set to 1 minutes
- Click OK twice to close properties
You now will have the current date updated every minute automatically. You can add formulas to calculate time elapsed from the "Invoked Function" table.
- ldcox8551Copper Contributor
Worked perfectly. Thank you very much. I've never used Query before and you made it very easy to figure out.
- Craig HatmakerIron Contributor
- ldcox8551Copper Contributor
Thank you for the information. I will try this now.