Hello forum,
I found this code in a different forum where it is scheduled to run once a month:
Private Sub Workbook_Open()
Dim bError As Boolean
Dim iLastMonth As Integer
Dim datLastRun As Date
On Error Resume Next
datLastRun = ThisWorkbook.CustomDocumentProperties.Item("LastRunDate")
bError = Err.Number <> 0
On Error GoTo 0
If bError = False Then iLastMonth = Month(datLastRun)
If iLastMonth <> Month(Date) Then
MsgBox "run your macro here"
With ThisWorkbook.CustomDocumentProperties
If bError Then
.Add Name:="LastRunDate", _
LinkToContent:=False, _
Type:=msoPropertyTypeDate, _
Value:=Date
Else
.Item("LastRunDate").Value = Date
End If
End With
End If
End Sub
i love this code because it stores the last run date in some inner library so that if the day was missed it will still run the next time the workbook is opened, but i don't know how to make this code run once a week. I can get it to run once a day because excel recognizes the code word "Day", but excel will not recognize the word "Week".
Any help on this would be greatly appreciated.
Thanks!
Bookmarks