Macro to run on Mon and Tues

  • Thread starter Thread starter salgud
  • Start date Start date
S

salgud

I'd like this macro to run only on Mon and Tues. This is what I wrote:

Sub Auto_Open()
If Weekday(Now()) = 2 Or 3 Then
Call CreateProjStatMenubar
End If
End Sub

But the macro runs every day. Any suggestions?
 
Sub Auto_Open()
If Weekday(Date) = 2 _
Or weekday(date) = 3 Then
Call CreateProjStatMenubar
End If
End Sub
 
Try

If Weekday(Now) = 2 Or Weekday(Now) = 3 Then
' your code here
End If

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Try this...

Sub Auto_Open()
If Weekday(Date, vbMonday) < 3 Then Call CreateProjStatMenubar
End Sub
 
It tests for if any of those is true:
Weekday(Now()) = 2
or
3
!
Test this:

Sub Test()
If 3 Then
MsgBox "ok"
End If
End Sub

... runs every day. Switch to
If Weekday(Now()) = 2 Or Weekday(Now()) = 3 Then

HTH. Best wishes Harald
 
I'd like this macro to run only on Mon and Tues. This is what I wrote:

Sub Auto_Open()
If Weekday(Now()) = 2 Or 3 Then
Call CreateProjStatMenubar
End If
End Sub

But the macro runs every day. Any suggestions?

Thanks to all!
 
Back
Top