Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Macro to run on Mon and Tues

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Macro to run on Mon and Tues


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)

On Fri, 6 Feb 2009 12:52:24 -0700, salgud
wrote:

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?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro to run on Mon and Tues

Try this...

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

--
Rick (MVP - Excel)


"salgud" wrote in message
.. .
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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Macro to run on Mon and Tues

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

"salgud" wrote in message
.. .
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?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Macro to run on Mon and Tues

On Fri, 6 Feb 2009 12:52:24 -0700, salgud wrote:

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!


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to run on Mon and Tues

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

salgud wrote:

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?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To INCREMENT days of the week? like mon,tues,wed,etc?? Robert Blass Excel Worksheet Functions 5 April 5th 23 02:50 PM
Function for generating all Mon, Tues, etc for each month RRutman Excel Worksheet Functions 1 July 18th 10 05:05 PM
Be Sure to vote for HUSSEIN OBAMA on Tues ALICIA PARKER Excel Discussion (Misc queries) 0 November 1st 08 02:56 PM
Figuring number of Mon. Tues. Wed between dates Paula Excel Worksheet Functions 12 October 30th 08 07:26 PM
In excel how set up a sequence to drag Mon, Tues, Wed Etc, miltdp Excel Discussion (Misc queries) 1 August 3rd 05 10:15 PM


All times are GMT +1. The time now is 10:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"