+ Reply to Thread
Results 1 to 5 of 5

I want to run macro when workbook is idle for N minutes

  1. #1
    Registered User
    Join Date
    02-12-2016
    Location
    Enugu
    MS-Off Ver
    enugu
    Posts
    50

    I want to run macro when workbook is idle for N minutes

    I stumbled through a solution>https://answers.microsoft.com/en-us/...cec8eda55?db=5

    The macro actually works but the downside is that the loop monitors worksheet change in a continuous cycle that disables every other modules from working.

    My question is like asking: is it possible for two macros to run concurrently? If no, what better macro can I use?
    I'm relatively new to VBA, a breakdown will be appreciated.
    Thanks.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: I want to run macro when workbook is idle for N minutes

    To answer your question; no, you cannot have two macros run concurrently.

    The solution below uses an On Time macro that runs after a specific time has passed. The code extends that specific time for various workbook events. If there are no workbook events (user is idle) then it runs your macro when the last set time is reached.

    Put this code in a standard code module e.g.; Module1. Set your Idle time and your macro name to suit.

    Please Login or Register  to view this content.

    Put this in the ThisWorkbook code module
    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 06-27-2018 at 02:35 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-12-2016
    Location
    Enugu
    MS-Off Ver
    enugu
    Posts
    50

    Re: I want to run macro when workbook is idle for N minutes

    @alphafrog Thanks!
    It works! But it seems like inserting or editing a chart does not reset the timer

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: I want to run macro when workbook is idle for N minutes

    Quote Originally Posted by chrismeeky View Post
    But it seems like inserting or editing a chart does not reset the timer
    You're welcome.

    Yes, this method is imperfect. Inserting\editing a chart is not a triggered event. I don't know how to get around that using this method. You'll likely discover a few other activities that are not recognized as well.

  5. #5
    Registered User
    Join Date
    02-12-2016
    Location
    Enugu
    MS-Off Ver
    enugu
    Posts
    50

    Re: I want to run macro when workbook is idle for N minutes

    @AlphaFrog. Since the user is not required to edit designs/insert charts, the macro is perfect. Thanks for helping!
    Chris.

+ 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. Replies: 14
    Last Post: 04-24-2018, 08:55 PM
  2. Vba Code to Lock the desktop if idle for 5 minutes
    By dasanb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2013, 08:40 AM
  3. [SOLVED] Userform idle for 1 minutes , how to close Workbook linked to it ?
    By stevnb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2012, 09:05 AM
  4. [SOLVED] Saving and closing workbook after idle time
    By bigmantitus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2012, 12:11 PM
  5. Macro that saves workbook every 4 minutes
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 06-22-2012, 03:45 AM
  6. Autoclosing an idle workbook on a locked workstation. Teething problems.
    By Davius in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2012, 04:48 AM
  7. Auto save and close workbook after user defined length of idle time
    By Nickster64 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-08-2008, 10:30 AM

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