+ Reply to Thread
Results 1 to 5 of 5

Error Fix [Runtime error 9]

  1. #1
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    334

    Error Fix [Runtime error 9]

    I am using the following code to rename worksheets

    Please Login or Register  to view this content.
    When it gets to the last worksheet I get a runtime error 9 subscript out of range on the line:

    Please Login or Register  to view this content.

    The code renames every other sheet as required.
    Any suggestions on how to fix the error??

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Error Fix [Runtime error 9]

    The line: arr = Range("b:b").Value
    loads the entire column B into the array so that the upper bound is: 65536
    Therefore, i will quickly get to an empty cell and crash.

    You need to find the last used cell in B such as:
    Please Login or Register  to view this content.
    Last edited by protonLeah; 11-30-2012 at 03:02 AM.
    Ben Van Johnson

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    If you remove that unneeded code what happens?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    10-23-2012
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: Error Fix [Runtime error 9]

    I am having the same run time error 9 issue using the following code and I have it in a range within 10 cells. It stops on the 4th one. Any suggestions or help would be greatly appreciated

    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Error Fix [Runtime error 9]

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ 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