+ Reply to Thread
Results 1 to 8 of 8

Runtimer call module

  1. #1
    Registered User
    Join Date
    02-21-2015
    Location
    Australia
    MS-Off Ver
    Excel - 2016 PC Vers 16.0.5404
    Posts
    13

    Runtimer call module

    On workbook open a module (calculate) is called, at the end of that module a Runtimer of 3mins calls to repeat the same module.

    Please Login or Register  to view this content.
    I have 2 issues

    1- If the workbook is closed but excel still open or i open a different workbook after 3 mins it reopens the previous workbook... Presuming that a Runtimer is executing somewhere in the background still.
    2 - If the first workbook is opened and i open another workbook after the 3 mins a runtime error occurs.

    Hopefully i have provided enough info that makes sense, feel free to ask additional questions I'll respond asap.
    Last edited by Mmmdonuts; 11-20-2023 at 06:27 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    23,754

    Re: Runtimer call module

    A timer is global to an Excel instance. It is not specific to a file. If the timer is set to call a Sub in a file, and that file is not open when the timer files, that file will be opened so it can execute. You should have code in Workbook_BeforeClose to cancel the timer.

    What runtime errors and on which line of code?

    To do any meaningful troubleshooting on this we need to see all your code, not just the part that you are guessing is the issue.

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however we recommend that you include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Guideline #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-21-2015
    Location
    Australia
    MS-Off Ver
    Excel - 2016 PC Vers 16.0.5404
    Posts
    13

    Re: Runtimer call module

    I included the Workbook_BeforeClose, this resolved issue 1.

    Issue 2
    Please Login or Register  to view this content.
    When i have another spreadsheet open after the timer it throws out a runtime error 9 subscript out of range. A debug shows this fault on line 2 of my code.
    Is there no way round of having my Timer non global? (sorry new to this).
    Basically, i want this spreadsheet open and updating in the background whilst working on another with no issues.
    Last edited by Mmmdonuts; 11-21-2023 at 04:27 PM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    23,754

    Re: Runtimer call module

    It is a best practice to not use Activate or Select and then assume through the rest of the code what is active or selected.

    Line 2 of your code has illegal syntax, it is just a text string. I don't know what you are intending to do here.

    I have rewritten your code with explicit qualifications, which hopefully resolves your runtime error.

    Try this version:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-21-2015
    Location
    Australia
    MS-Off Ver
    Excel - 2016 PC Vers 16.0.5404
    Posts
    13

    Re: Runtimer call module

    Apologies i messed up when pasting code. I have edited it, hopefully makes more sense now.

    Would there be anything to add to your reply now you have a better picture?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    23,754

    Re: Runtimer call module

    Just apply the same principles I used to any code that you didn't include the first time. Don't use Select or Activate, and ensure every use of Range has a qualification. I'll help with it later today if I get a little time.

  7. #7
    Registered User
    Join Date
    02-21-2015
    Location
    Australia
    MS-Off Ver
    Excel - 2016 PC Vers 16.0.5404
    Posts
    13

    Re: Runtimer call module

    My code runs on the sheet "Data" - Just mentioning this in case you didn't realize then it calls back to the dashboard.
    I had the Data tab hidden as i don't want anyone to muck with it. I've unhidden it always now as i have read elsewhere it can cause issues.

    Still having issues when another workbook is open. it now faults (same fault) at Sheets("Data").Select
    Also, I've left in the 2 statements below as my screen flashes and annoys me.
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Please Login or Register  to view this content.

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    23,754

    Re: Runtimer call module

    Quote Originally Posted by Mmmdonuts View Post
    Still having issues when another workbook is open.
    It does not appear that you followed any of my recommendations to solve that.

+ 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. Call sub from another module
    By stolba in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-03-2016, 01:00 PM
  2. [SOLVED] How can I call a Module or a sub procedure and run it automatically in current module?
    By qzqzjcjp in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2014, 11:48 AM
  3. I cant call a sub i have in a module
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-16-2014, 08:29 PM
  4. [SOLVED] VBA code: A Sub() module to CALL another Sub ()
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-07-2013, 08:48 AM
  5. call/run module
    By Pedroluna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-24-2011, 07:54 PM
  6. [SOLVED] Call a Module
    By mb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2005, 09:05 PM
  7. Call other sub in the same module
    By yangyh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2005, 05:05 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