+ Reply to Thread
Results 1 to 3 of 3

When looping through Workbooks calling Macro - Run-time error '9': Subscript out of range

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    When looping through Workbooks calling Macro - Run-time error '9': Subscript out of range

    Hello folks,

    The below code loops through several .xlsm workbooks, calling the Startx macro for each workbook.
    Most times it works perfectly, but, eventually, I get the following error:

    Run-time error '9':
    Subscript out of range

    Then on this same message box there are the buttons: End, Debug and Help

    When I click on Debug, it highlights this part of below code:

    Please Login or Register  to view this content.
    Then I simply need to click on Play button, and it continues the macro until it completes successfully.

    In order to try to fix this issue I tried to minimize the screen of AllWorkbooks macro, but it did not work.

    Does anybody has any idea on what I need to do to solve this?


    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: When looping through Workbooks calling Macro - Run-time error '9': Subscript out of ra

    When the code stops(gives the error mentioned above), I checked MyFile value and it contains the correct Workbook Name... By somehow it is stopping on that part.

  3. #3
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007 & 2013
    Posts
    268

    Re: When looping through Workbooks calling Macro - Run-time error '9': Subscript out of ra

    I found where the error was. On mine last module of Startx module, I call a module that saves the worksheet data in TXT format, which opens a new workbook to do the work(to save the TXT file), and this was messing up the loop through Workbooks on module AllWorkbooks. Thanks!

+ 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. Macro - Run Time Error 9 (Subscript out of range)
    By Joshdm0716 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2014, 07:50 AM
  2. Run-time error 9: subscript out of range when trying to close workbooks
    By jhigashi in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2013, 09:04 PM
  3. Help!! - Subscript Out of Range - Error while calling a workbook frmm another sheet..
    By ragavendraph in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-29-2012, 12:53 PM
  4. Replies: 1
    Last Post: 08-04-2011, 09:57 AM
  5. fix a macro that gets a run-time error '9' subscript out of range
    By kellys in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2006, 03:55 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