Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to start macro at every month......... (2000 sr 1)

    i use this line to autostart a macro at 15 minuts (i have unsert in event auto open Thisworkbook)
    Application.OnTime Now + TimeValue("00:15:00"), "MyMacro"

    But how to start this amcro at every fifteen days of aech month......

    Example:

    i open the wbook 20/11/2005, naturally 15/11/21005 is already gone, autostart MyMacro...
    i open the wbook 15/12/2005 autostart MyMacro...

  2. #2
    5 Star Lounger
    Join Date
    Apr 2003
    Location
    Hampshire, United Kingdom
    Posts
    602
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to start macro at every month......... (20

    Day(Date) will give you the "day" part of today's date. So the code you need is:

    Private Sub Workbook_Open()
    If Day(Date) >= 15 Then MyMacro
    End Sub

    <font color=red>NOTE:</font color=red> This will make MyMacro run every time you open the workbook on or after 15th of each month. To run the macro just once each month, you'll need to store an indicator in your workbook telling you whether or not the macro has been run for the current month.
    Waggers
    If at first you do succeed, you&#39;ve probably missed something.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: How to start macro at every month......... (2000 sr 1)

    I think the windows scheduler may be more appropriate. You can schedule to have XL run and open a particular file

    To use OnTime would require XL always be open and loop thru running every day to check on the day...

    In my Win XP it is Start - Programs - Accessories - system tools - scheduled tasks
    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •