Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'Code goes in regular module sheet, with Public declarations before any subs or functions
Public RunWhen As Double
Public Const cRunWhat = "UpdateDay"
Sub StartTimer()
'You need to pick the next time to run the UpdateDay sub. Use one of the following statements customized to your situation
RunWhen = IIf(Hour(Now) =23, 1, 0) + Int(Now) + TimeSerial(23, 50, 0) 'Run every night at 11:50 PM
'RunWhen = Int(Now) + TimeSerial(Hour(Now) + 1, 0, 0) 'Run every hour, on the hour
'RunWhen = Int(Now) + TimeSerial(Hour(Now), Minute(Now) + 1, 0) 'Run every minute, on the minute
'RunWhen = Int(Now) + Int((Now - Int(Now)) * 1440 / 10 + 1) / (1440 / 10) 'Run every 10 minutes, on the dot
'RunWhen = Now + 5 / 86400 'Run every 5 seconds. With intervals this short, use a Boolean switch to stop the timer
'The next five statements are optional. They create a Boolean switch to control whether the timer runs.
Dim rg As Range
On Error Resume Next
Set rg = Range("StopTimer")
If rg Is Nothing Then ActiveWorkbook.Names.Add "StopTimer", "=TRUE"
On Error GoTo 0
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=True
End Sub
Sub UpdateDay()
Dim i As Long
With Worksheets("Sheet1") 'Change to worksheet name you want to update
.Cells(65536, 1) = Day(Date)
.Cells(65536, 1).Copy
.[A1:B50].PasteSpecial Paste:=xlPasteAll, Operation:=xlAdd 'Change to cell address you want to update
.Cells(65536, 1).Clear
i = .UsedRange.Rows.Count
End With
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
'Range("StopTimer")=False 'Use this statement if time interval between calls is short
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=False
End Sub
'Code goes in ThisWorkbook code pane. It won't work anywhere else!
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub
Private Sub Workbook_Open()
RunWhen = IIf(Hour(Now) =23, 1, 0) + Int(Now) + TimeSerial(23, 50, 0) 'Run every night at 11:50 PM
Application.OnTime RunWhen, "UpdateDay"
End Sub
With Cells(Day(YourDate), "A")
.Offset(0,0).value = .Row
.Offset(0,1).value = YourDate
for i = 0 to 6
.Offset(0,2+i).value = YourDDE(i)
next
End With
lNextRow = [A1].CurrentRegion.Rows.Count + 1
With Cells(lNextRow, "A")
.Offset(0,0).value = Day(YourDate)
.Offset(0,1).value = YourDate
for i = 0 to 6
.Offset(0,2+i).value = YourDDE(i)
next
With