+ Reply to Thread
Results 1 to 8 of 8

Running Macro at regular intervals.

  1. #1
    Registered User
    Join Date
    04-16-2008
    Posts
    19

    Running Macro at regular intervals.

    Is there anyway in which I can run macro at regular intervals.

    For example, Macro1 to be run every 180 minutes.

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Have a look at the application.ontime method.

    There are plenty of examples on the forum, as well as the excel vba help file.

    rylo

  3. #3
    Registered User
    Join Date
    04-16-2008
    Posts
    19
    Please Login or Register  to view this content.
    Thanks for the info

    Ok... I use the above code for running Macro2 every 1 hour. But I am having a problem here.. the Macro2 itself takes 3 - 5 mins (varies at different times) to run. Due to this the Macro2 doesnt run exactly at 1 hour. It runs at 63 - 65 minutes due to the time taken by macro2.

    Is there anyway in which I can get it run exactly 1 hour which includes the macro running time also.

    Any help regarding this would be much appreciated.

    Plz let me know if you require any more info

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    You could call the starttimer at the start of macro2
    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.

  5. #5
    Registered User
    Join Date
    04-16-2008
    Posts
    19
    The problem if I put the starttimer at the beginning is:

    The starttimer will run exactly in 1 hour after the function is called thus running the Macro2. After this, immediately the Macro2 will repeat once again. (coz the code lies below it)

    But I want this to run only once every 1 hour

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    MAcro2 starts to run
    It calls the Starttimer macro which sets the time that macro2 is to run (i hour in the future)
    After starttimer has run macro2 continues to run

    Do not call starttimer again from macro2

    Macro2 will only run once per hour & exactly 1 hour from when macro2 was last run

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-16-2008
    Posts
    19
    Got it Thanks .. Checking this now :P

  8. #8
    Registered User
    Join Date
    04-16-2008
    Posts
    19
    Works perfect

    Thanks a lots

+ 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