+ Reply to Thread
Results 1 to 8 of 8

Stop timed macro on close

  1. #1
    Registered User
    Join Date
    09-25-2008
    Location
    NJ
    Posts
    15

    Stop timed macro on close

    I have the following macro to recalculate the time every second on opening a spreadsheet

    Sub Auto_Open()
    Calculate
    Application.OnTime Now + TimeValue("00:00:01"), "Auto_open"
    End Sub

    Looking for the code I need to add that will stop the macro when the file is closed.

    Many thanks
    Last edited by Allardin; 10-06-2008 at 07:20 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    From Help for OnTime:

    This example cancels the OnTime setting from the previous example.
    Please Login or Register  to view this content.
    Please read the Forum Rules and then edit your post to wrap your code with Code Tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-25-2008
    Location
    NJ
    Posts
    15
    I am a novice, and this took me quite a while to do....do I simply add your code? I simply (or not so simply) want the spreadsheet to stop the macro and close when the file closes

    Please Login or Register  to view this content.
    Thanks
    Last edited by VBA Noob; 09-26-2008 at 01:55 AM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Allardin,

    Please read the Forum Rules and then edit your post to wrap your code with Code Tags, and I'll help you.

  5. #5
    Registered User
    Join Date
    09-25-2008
    Location
    NJ
    Posts
    15
    I am a novice, and this took me quite a while to do....do I simply add your code? I simply (or not so simply) want the spreadsheet to stop the macro and close when the file closes

    Please Login or Register  to view this content.
    Thanks
    Sorry for not putting in code previously

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Thank you.

    Put this in the ThisWorkbook module:
    Please Login or Register  to view this content.
    Put this in a code module:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-25-2008
    Location
    NJ
    Posts
    15
    WOW
    I really appreciate your expert help. Embarrassed to say how much time I spent on what I did.

    Really, can't thank you enough

    What's reference/s would you recommend reading?

    Many thanks again

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Glad it worked for you.

    Pick one of the Walkenbach books.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Delete Sheets on close macro
    By richardeallen in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-24-2008, 05:46 AM
  2. How to Stop a Macro Safely?
    By game in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2007, 06:56 PM
  3. Record Macro Stop Button
    By lwmweb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2007, 09:13 PM
  4. Macro won't stop running!
    By wizard007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-05-2007, 06:09 AM
  5. Help: How to stop macro security warning
    By cabezahueco in forum Excel General
    Replies: 2
    Last Post: 10-27-2006, 02:10 PM

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