What's in Workbook_Open ???
What's the name of the macro you want to run on friday morning?
My idea:
Place the code below in a Module
The Red line of code is the topmost outside the subs
Global LapTime2 As Date
Public Sub setFridayMorningRun()
Dim tDays As Integer
tDays = Choose(Weekday(Date), 5, 4, 3, 2, 1, 0, 6)
If tDays = 0 Then
If Time > TimeValue("08:47 AM") Then tDays = tDays + 7
End If
LapTime2 = (Date + tDays) + TimeSerial(8, 47, 0)
Application.OnTime LapTime2, "RunOneTimeOnFridayMorn"
End Sub
Public Sub stopFridayMorningRun()
On Error Resume Next
Application.OnTime Earliesttime:=LapTime2, Process:="RunOneTimeOnFridayMorn", Schedule:=Flase
Err.Clear
On Error GoTo 0
End Sub
Public Sub RunOneTimeOnFridayMorn()
' here the code you want to run on friday morning
' when it completes you run setFridayMorningRun again
setFridayMorningRun
End Sub
In the Workbook_Open event
Private Sub Workbook_Open()
setFridayMorningRun
End Sub
So every time the workbook is opened the macro is set to run on a friday at 8 47 AM
I also suggest you place this in the
Private Sub Workbook_BeforeClose(Cancel As Boolean)
stopFridayMorningRun
End Sub
Bookmarks