The attach file button doesn't work - click "Go Advanced" to the lower right of the edit window, then use the "Manage attachments" option.
Save your file as a macro-enabled .xlsm and change "SheetName" in two places in the code to the actual sheet name.
With this in a regular code module:
Option Explicit
Dim NextTime As Date
Sub ScheduleRun()
'Schedule for 1600
NextTime = Date + 1600 / 2400
Application.OnTime NextTime, "RunMe"
End Sub
Sub RunMe()
Dim shW As Worksheet
Set shW = ThisWorkbook.Worksheets("SheetName")
shW.Cells(shW.Rows.Count, "A").End(xlUp)(2).Value = Date
shW.Cells(shW.Rows.Count, "A").End(xlUp)(1, 2).Value = shW.Range("A1").Value
End Sub
Sub StopMe()
'Un-schedule for today...
Application.OnTime NextTime, "RunMe", Schedule:=False
End Sub
And this in the codemodule of the ThisWorkbook object:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim shW As Worksheet
Set shW = ThisWorkbook.Worksheets("SheetName")
If shW.Cells(shW.Rows.Count, "A").End(xlUp).Value = Date Then Exit Sub
StopMe
RunMe
End Sub
Private Sub Workbook_Open()
ScheduleRun
End Sub
Bookmarks