+ Reply to Thread
Results 1 to 9 of 9

Runtime error 9: Subscript out of range

  1. #1
    Registered User
    Join Date
    09-24-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    26

    Runtime error 9: Subscript out of range

    Hi Guys & Gals,
    Im having a shocker with the code below, it works on some pc's on my company network but not all. Basically i am trying to copy data from one opened spreadsheet and paste it into a master document. I have confirmed that all spreadsheets are opened in the same instance of excel (by using file/open). Everyone is on the same version of Excel, 2007. The people that it doesnt work for are in a different office location, but we're all on the same network. Ive read every solution on this error that i can find, but have never been able to solve it (for months now we've been getting people whos pc it runs on to run the macro for us)..
    Any ideas? the debugger shows the code breaking on
    Please Login or Register  to view this content.
    Many thanks in advance!
    Dave

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Runtime error 9: Subscript out of range

    The line
    Please Login or Register  to view this content.
    assumes you have opened this workbook but I see no code in your macro checking that this file is opened and if not opens the file before trying to activating it.

    Alf

  3. #3
    Registered User
    Join Date
    09-24-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Runtime error 9: Subscript out of range

    Thanks Alf, Yea i have definitely opened that workbook,infact the macro runs from within this workbook

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Runtime error 9: Subscript out of range

    Yea i have definitely opened that workbook
    Strange as the most obvious reason for a runtime error 9 is that excel can't find the workbook. Perhaps you could test using the index value for those who do get the runtime error 9.

    Excel assigns index values to workbooks as you open them. The first workbook opened has an index value of 1, the second workbook opened has an index value of 2, and so on.
    So if "performance uploader v11.0.xlsm" is the first workbook to be opened then
    Please Login or Register  to view this content.
    should activate "performance uploader v11.0.xlsm".

    I would suggest you only use the index method for testing as this is an "unstable" method for activating workbooks i.e. close the 1st workbook and the previous second workbook now becomes the first workbook.

    Alf

  5. #5
    Registered User
    Join Date
    09-24-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Runtime error 9: Subscript out of range

    Thanks Alf ill give it a go and revert back!

  6. #6
    Registered User
    Join Date
    09-24-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Runtime error 9: Subscript out of range

    No Luck with indexing im afraid Alf, Anybody any other ideas, anybody? it seems to have everyone i ask stumped, all i can come up with is that its something to do with the network set up... the only problem i have with that is when i connect my laptop to the same network it works fine (remembering we have people in 2 locations, the one thats failing is a regional location, i have gone there with my laptop though and it worked fine)

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Runtime error 9: Subscript out of range

    Hi David,

    One thing to check is that both workbooks are in the same session of Excel. See here for a similar thread I answered which may help.

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  8. #8
    Registered User
    Join Date
    09-24-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Runtime error 9: Subscript out of range

    Thanks Robert, yes i have confirmed the same instance by using excels "file/open" to open the files, its a real stumper!

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Runtime error 9: Subscript out of range

    Try recording a simple macro while you manually toggle between the workbooks with the files that are causing the issue and check your code against that. Also ensure there's no references in the Visual Basic Editor (Tools > References menu from within your code) that start with MISSING.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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