Macro to run on Mon and Tues

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?
 
D

Dave Peterson

Sub Auto_Open()
If Weekday(Date) = 2 _
Or weekday(date) = 3 Then
Call CreateProjStatMenubar
End If
End Sub
 
C

Chip Pearson

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)
 
R

Rick Rothstein

Try this...

Sub Auto_Open()
If Weekday(Date, vbMonday) < 3 Then Call CreateProjStatMenubar
End Sub
 
H

Harald Staff

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
 
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?

Thanks to all!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top