+ Reply to Thread
Results 1 to 4 of 4

created:Run macro based on current date

Hybrid View

yaju1120 created:Run macro based on... 11-28-2007, 10:28 AM
jasoncw See if this works for you: ... 11-28-2007, 10:52 AM
yaju1120 Thanks! 11-28-2007, 01:11 PM
mudraker When testing the same item... 11-28-2007, 04:32 PM
  1. #1
    Registered User
    Join Date
    06-28-2007
    Posts
    27

    created:Run macro based on current date

    I have created a macro for each of the months in the year that I'd like to automatically run depending on the month we're in.

    I've tried using the MonthName variable and the Now function, but it doesn't work. My code is as follows:

    If MonthName.(Now()) = "July"
    Application.Run "Project Budget.xls'!July"
    
    Else If MonthName.(Now())="August"
    Application.Run "Project Budget.xls'!July"
    Application.Run "Project Budget.xls'!August"
    I'd really appreciate any help I can get on this...

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    See if this works for you:
    If Month(Date) = 7 Then
        Application.Run "Project Budget.xls'!July"
    
    ElseIf Month(Date) = 8 Then
        Application.Run "Project Budget.xls'!July"
        Application.Run "Project Budget.xls'!August"
    
    End If
    HTH

    Jason

  3. #3
    Registered User
    Join Date
    06-28-2007
    Posts
    27

    Thanks!

    Jason,

    Thanks a bunch for the help...It works to perfection.

    J.

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    When testing the same item for mulriple results I recommend using Select Case statements


    Select Case Month(Date)
    Case 7
        Application.Run "Project Budget.xls'!July"
    Case 8
        Application.Run "Project Budget.xls'!July"
        Application.Run "Project Budget.xls'!August"
    End Select
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1