Run-time error '9': Subscript out of range (VisualBasic) RRS feed

  • Question

  • Dear Sir,
    I must use excel files (made in Excel 98-2003, or *.xlsm) which sent me an error message after opening. Files are not created by me. (I'm not a VisualBasic specialist. I can't write new scripts.) Other user haven't such problem with that but I always get this message:   Run-time error '9':  Subscript out of range.

    Of course file is opened but doesn't work correctly. I asked for help but such problem is unknown for others.
    Re-installing was not solution, problem is current.

    • When and why is sent such message?
    • Cause origin  of hardware? (Too slowly? Memory stick? Processor speed? Run-time...)
    • Does my Excel version have an reduced functionality? Are not all subscript built-in?  
      (Home and student version, 2016)
    • Is it a software-bug?
    • Is it nor available for using old generations VisualBasic ? (compatibiliy?)

    Can I do something to solve this problem?
    Can somebody help me?
    Thnak a lot.

    Wednesday, June 20, 2018 4:28 AM

All replies

  • Post the line of code that it stops on.

    If not too much code then also post the entire sub and tell us which is the problem line of code.

    Regards, OssieMac

    Wednesday, June 20, 2018 6:22 AM
  • Hi,

    This is the forum to discuss questions and feedback for Microsoft Excel features, I'll move your question to the MSDN forum for Excel

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.



    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, June 20, 2018 7:47 AM
  • Hello, I am not a coder but a user. Code must be OK, because others can use it. (Not on my computer, not with same excel version, they are not specialist too.)

    I think there is any configuration of excel 2016 home and student which blocks it's running. I have seeked it in 'data protection', i have made a lot of enable function, but there is not result.

    Thx & Regards 

    Saturday, June 23, 2018 3:55 PM
  • I am afraid that without the code that is causing the problem one can only guess. When the problem occurs is the VBA editor opened and highlighting the problem line of code? If not, then the code is probably protected but if it is displayed, then copy the code and paste into a reply here and indicate which line was highlighted. Even if the problem is only on one computer, knowing which line of code is the problem can assist in providing a solution.

    If the code is protected, you might need to go back to the developer so they can unprotect the code and see what line of code is the problem and from there probably provide a solution.

    Is the workbook accessed from a shared point or is it individually loaded on each computer? If the latter, have you tried obtaining a copy of the workbook from one of the computers on which it is working? (It is possible that your copy of the workbook is corrupted.)

    Have you done anything with inserting or moving Page Breaks? If so, remove them. See the following link for how to do this. There is a known problem with VBA when it can returns error 9 due to location of Page Breaks.

    Do you have the same virus/internet security software as the other computers? You could try disabling the security and see if it makes a difference and if it does then find out what changes you need to the antivirus software setup/options.

    Regards, OssieMac

    Saturday, June 23, 2018 9:52 PM