+ Reply to Thread
Results 1 to 6 of 6

Timed Macro

  1. #1
    Registered User
    Join Date
    10-08-2010
    Location
    MK, UK
    MS-Off Ver
    Excel 2003
    Posts
    70

    Red face Timed Macro

    Hi

    Is it possible to have Excel open, with a Macro running that will every two hours inport some data from a source then open a new tab in a different work book and paste it into that tab then close the workbook.

    I have the code for inporting the data to the first workbook done, its the timing and copying to a new tab in a different workbook im stuck with.

    Once it has imported the data, copied it to a new tab in the other workbook, I would like it to wait two hours then do it again, and keep running.

    Any ideas ??

    Thanks
    David

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Timed Macro ??

    Hello David,

    Do you want to copy the same sheet, after it has updated, and create a new workbook with this single sheet?

    How will these new workbooks be named?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    10-08-2010
    Location
    MK, UK
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: Timed Macro ??

    Hi

    I have one workbook called "current" and one called "history"

    What I would like to happen is,

    1. Workbook "current" stays open all the time with 1 worksheet called "currentdata"
    2. Every 2 hours I woul like the macro with in "current" to update the data in this worksheet with new data.
    3. Next copy all the data from this worksheet, in to a new tab in the workbook "history" close this workbook.
    4. then start the cycle again.

    Hope that explains.

    Thanks
    David

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Timed Macro ??

    Hello David,

    Thanks for the explanation. Just so I am clear, a new worksheet will be added to the "History" workbook every 2 hours, correct? Do you want this to start as soon "Current" is opened or at a specific time, like 9:00 am?

  5. #5
    Registered User
    Join Date
    10-08-2010
    Location
    MK, UK
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: Timed Macro ??

    Hi

    Yes, that is spot on.

    A spefic time would be best, so I can leave the "current" work book open and not worry about what the time is.

    Im thinking 10:00am then every 2 hours until I break the code or close down "current"

    Thanks
    David

  6. #6
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: Timed Macro ??

    The "OnTime" command will allow you to run a macro at a specific time or loop every n minutes ..

    Heres a link to a nice little tutorial on it ... CAUTION : be carefull in setting up as you will need to cancel the command on closing.
    http://www.ozgrid.com/Excel/run-macro-on-time.htm

+ 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