+ Reply to Thread
Results 1 to 9 of 9

Run-time error 9 - subscript out of range

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Run-time error 9 - subscript out of range

    Hi all,

    recently, Charles helped me develop some code (thx, Charles) which, when I ran it on my machine, executed all the code perfectly. Now I find that when I run the same code on my girlfriend's machine, I get the error.

    Both of the workbooks are in the root directory of my USB thumb drive and both workbooks are open when running the code - works on my machine but not on hers.

    We both have Win 7 Ultimate and Excel 2010 on our machines. We both have the same add-ins running in Excel and I even reassigned the driver letter on her machine to "S" so that it matched mine at home but still, no luck.

    I'm at a loss as to what might be causing it and wondered if anyone had any ideas?

    I've included the code below for perusal - when it brings up the error on her machine the code stops ar the line I've highlighted in red.

    Please Login or Register  to view this content.
    Thanks in advance for any suggestions.

    AJ
    Last edited by ScotyB; 05-21-2012 at 09:48 PM. Reason: to mark as 'solved'
    Always grateful for the help here - thanks.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Run-time error 9 - subscript out of range

    The variable Rlrow isn't defined in this bit of code. What type is it?

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Run-time error 9 - subscript out of range

    always use the file extension when referring to a workbook
    Please Login or Register  to view this content.
    for example. btw you have several unqualified range references in the code which is not ideal
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  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

    Re: Run-time error 9 - subscript out of range

    You have Explorer configured to suppress extensions for known file types, your girfriend doesn't, which is better practice.

    +1 for Joseph's suggestion.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: Run-time error 9 - subscript out of range

    Quote Originally Posted by dangelor View Post
    The variable Rlrow isn't defined in this bit of code. What type is it?
    Aah, I'd forgotten that - I think I originally had it as String or Long - I'll check it again.

    Thanks, dangelor.

  6. #6
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: Run-time error 9 - subscript out of range

    Quote Originally Posted by JosephP View Post
    always use the file extension when referring to a workbook
    Please Login or Register  to view this content.
    for example. btw you have several unqualified range references in the code which is not ideal
    Thanks, Joseph, I'll add the extension and try it again - could you point out where I'm missing range references? (I'm still new to vBa and the code was set up for me by someone else)

  7. #7
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: Run-time error 9 - subscript out of range

    Quote Originally Posted by shg View Post
    You have Explorer configured to suppress extensions for known file types, your girfriend doesn't, which is better practice.

    +1 for Joseph's suggestion.
    Thanks, shg, I'll be sure to check that as well.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Run-time error 9 - subscript out of range

    here for example
    Please Login or Register  to view this content.
    you haven't specified the sheet for the range so you are relying on Data being the active sheet. you also have a worksheet variable you aren't using so your code could be something like this (untested):
    Please Login or Register  to view this content.
    Last edited by JosephP; 05-22-2012 at 04:44 AM.

  9. #9
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: Run-time error 9 - subscript out of range

    dangelor, Joesph, and shg,

    I implemented all the suggestions you offered for my problem, and guess what? No more run-time error, yay! Thank you very much for your time and effort and since I can't be 100% certain which was the definitive solution to the problem, I guess I'll just have to give you ALL a gold star, lol.

    Many thanks,

    AJ

+ 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