Forum

MsgBox on alternate...
 
Notifications
Clear all

MsgBox on alternate days

4 Posts
2 Users
0 Reactions
126 Views
(@blackvan)
Posts: 30
Trusted Member
Topic starter
 

How can I trigger a MsgBox on alternate days?

Eg. open a MsgBox beginning on, say, Monday, then cycle through Wed, Fri, Sun, Tue, Thu, Sat, Mon repeat etc.

Or, put another way, start on DateX, then DateX + 2, DateX + 4, DateX + 6 etc.

 

I'd prefer the first way rather than rely on any specific start date 🙂

 
Posted : 10/09/2024 1:14 am
(@kjbox)
Posts: 69
Trusted Member
 

Find a cell somewhere in your workbook, enter a 2 (todays weekday number) and give that cell a defined name "NxtMsgDay" (without the quotes).

Then add this code to the ThisWorkbook Object module

Private Sub Workbook_Open()
If Weekday(Date) = [NxtMsgDay] Then
MsgBox "here is the message" 'Change as required
[NxtMsgDay] = [NxtMsgDay] + 2
If [NxtMsgDay] = 8 Then
[NxtMsgDay] = 1
ElseIf [NxtMsgDay] = 9 Then
[NxtMsgDay] = 2
End If
End If
End Sub

Close the workbook, saving it as macro enabled if not already a .xlsm file. Then reopen and you will get the message, the NxtMsgDay  cell will increase by 2 and message will be seen again when file gets opened on Wednesday, then again on Friday and so on.

 
Posted : 10/09/2024 3:51 am
(@blackvan)
Posts: 30
Trusted Member
Topic starter
 

Thank you Charles!

 
Posted : 11/09/2024 1:02 am
(@kjbox)
Posts: 69
Trusted Member
 

You're welcome.

 
Posted : 12/09/2024 7:20 am
Share: