Automatic Date Update (No Interaction)

%3CLINGO-SUB%20id%3D%22lingo-sub-1644253%22%20slang%3D%22en-US%22%3EAutomatic%20Date%20Update%20(No%20Interaction)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1644253%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20have%20a%20file%20I%20wish%20to%20have%20displayed%20on%20a%20TV%2024%2F7%20in%20which%20a%20counter%20shows%20how%20many%20days%20since%20an%20event%20last%20occurred.%20The%20only%20time%20interaction%20with%20the%20file%20would%20occur%20would%20be%20to%20update%20the%20last%20event%20date.%20Besides%20that%2C%20I%20am%20trying%20to%20have%20it%20where%20with%20the%20file%20remaining%20open%20and%20with%20no%20human%20interaction%20will%20still%20stay%20updated%20as%20to%20the%20current%20date.%20I%20tried%20making%20the%20date%20an%20external%20connection%20and%20setting%20the%20auto-refresh%20up%20on%20it%2C%20but%20it%20changes%20itself%20from%20a%20forumla%20to%20the%20last%20refresh%20cycle%20and%20locks%20there%20until%20changed%20again%20manually.%20Any%20thoughts%20or%20ideas%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1644253%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1644562%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Date%20Update%20(No%20Interaction)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1644562%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F785729%22%20target%3D%22_blank%22%3E%40ldcox8551%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20data%20source%20can%20be%20set%20to%20auto-refresh%20and%20almost%20all%20data%20sources%20have%20a%20system%20time%20function%20that%20can%20be%20returned%20to%20Excel%20using%20MS%20Query%20or%20PowerQuery.%20Here%20is%20the%20PQ%20example%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3E%26nbsp%3BIn%20Excel%20use%20menu%20option%3A%20Data%20%26gt%3B%20New%20Query%20%26gt%3B%20From%20other%20sources%20%26gt%3B%20Blank%20Query%3C%2FLI%3E%3CLI%3E%26nbsp%3BIn%20PQ%20use%20menu%20option%20Advanced%20Editor%20and%20make%20this%20edit%3CBR%20%2F%3Elet%3CBR%20%2F%3ESource%20%3D%20DateTime.LocalNow%3CBR%20%2F%3Ein%3CBR%20%2F%3ESource%3C%2FLI%3E%3CLI%3EClick%20%3CSTRONG%3EDone%3C%2FSTRONG%3E%3C%2FLI%3E%3CLI%3EClick%20%3CSTRONG%3EInvoke%3C%2FSTRONG%3E%3C%2FLI%3E%3CLI%3EClick%20%3CSTRONG%3EFile%3C%2FSTRONG%3E%20%26gt%3B%20%3CSTRONG%3EClose%20%26amp%3B%20Load%3C%2FSTRONG%3E%3C%2FLI%3E%3CLI%3EIn%20Excel%20click%20%3CSTRONG%3ETable%20Tools%20Design%3C%2FSTRONG%3E%20%26gt%3B%20%3CSTRONG%3EProperties%3C%2FSTRONG%3E%3C%2FLI%3E%3CLI%3EClick%20small%20icon%20(connection%20properties)%20next%20to%20Name%3A%3C%2FLI%3E%3CLI%3ECheck%20%3CSTRONG%3ERefresh%20Every%3C%2FSTRONG%3E%20and%20set%20to%201%20minutes%3C%2FLI%3E%3CLI%3EClick%20OK%20twice%20to%20close%20properties%3C%2FLI%3E%3C%2FOL%3E%3CP%3EYou%20now%20will%20have%20the%20current%20date%20updated%20every%20minute%20automatically.%20You%20can%20add%20formulas%20to%20calculate%20time%20elapsed%20from%20the%20%22Invoked%20Function%22%20table.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1644895%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Date%20Update%20(No%20Interaction)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1644895%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F234290%22%20target%3D%22_blank%22%3E%40Craig%20Hatmaker%3C%2FA%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20information.%20I%20will%20try%20this%20now.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1644896%22%20slang%3D%22en-US%22%3ERe%3A%20Automatic%20Date%20Update%20(No%20Interaction)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1644896%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F785729%22%20target%3D%22_blank%22%3E%40ldcox8551%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EAlternatively%2C%20you%20can%20add%20a%20clock%20in%20your%20spreadsheet%20with%20a%20macro.%20This%20will%20write%20the%20current%20date%20in%20cell%20A1%20and%20current%20date%20in%20cell%20A2.%20Since%20it%20refresh%20every%20second%2C%20your%20spreadsheet%20will%20recalculate%20every%20second.%20Execute%20%22SetTime%22%20to%20start%20the%20process%20and%20%22Disable%22%20to%20stop%20the%20process.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDim%20SchedRecalc%20As%20Date%3C%2FP%3E%3CP%3ESub%20Recalc()%3C%2FP%3E%3CP%3EWith%20Sheet1.Range(%22A1%22)%3C%2FP%3E%3CP%3E.Value%20%3D%20Format(Date)%3C%2FP%3E%3CP%3EEnd%20With%3C%2FP%3E%3CP%3EWith%20Sheet1.Range(%22A2%22)%3C%2FP%3E%3CP%3E.Value%20%3D%20Format(Time%2C%20%22hh%3Amm%3Ass%20AM%2FPM%22)%3C%2FP%3E%3CP%3EEnd%20With%3C%2FP%3E%3CP%3ECall%20SetTime%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3ESub%20SetTime()%3C%2FP%3E%3CP%3ESchedRecalc%20%3D%20Now%20%2B%20TimeValue(%2200%3A00%3A01%22)%3C%2FP%3E%3CP%3EApplication.OnTime%20SchedRecalc%2C%20%22Recalc%22%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3ESub%20Disable()%3C%2FP%3E%3CP%3EOn%20Error%20Resume%20Next%3C%2FP%3E%3CP%3EApplication.OnTime%20EarliestTime%3A%3DSchedRecalc%2C%20Procedure%3A%3D%22Recalc%22%2C%20Schedule%3A%3DFalse%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EP.S.%20I%20copied%20this%20macro%20from%20another%20source.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

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

@ldcox8551 

 

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:

 

  1.  In Excel use menu option: Data > New Query > From other sources > Blank Query
  2.  In PQ use menu option Advanced Editor and make this edit
    let
    Source = DateTime.LocalNow
    in
    Source
  3. Click Done
  4. Click Invoke
  5. Click File > Close & Load
  6. In Excel click Table Tools Design > Properties
  7. Click small icon (connection properties) next to Name:
  8. Check Refresh Every and set to 1 minutes
  9. 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. 

@Craig Hatmaker  

Thank you for the information. I will try this now. 

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 Hatmaker 

Worked perfectly. Thank you very much. I've never used Query before and you made it very easy to figure out. 

@ldcox8551Glad it worked for you. BTW - I like @Bennadeau's solution. If you need updates quicker than 1 minute, use it. If not, my PQ approach does not require VBA. I love VBA, but then, I'm a coder and not everyone is. VBA can also trigger security alerts. 

@Bennadeau 

The other solutions works for what I need but I am curious to learn this method as well for future knowledge. Thank you for sharing. I will play around with this some too.