+ Reply to Thread
Results 1 to 4 of 4

Run-time error 9: Subscript out of Range

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Run-time error 9: Subscript out of Range

    I am getting the Run-time error 9 message ...with this statement (or a variation ) There are no spelling issues. The sheet exist and....cannot figure out why.
    Any suggestions what this could be. Started excel a few times but keep getting hit

    Worksheets("Sheet3").Range("A17").value = "Test"

    Thank you

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Run-time error 9: Subscript out of Range

    Are you using this code in workbook1 while the sheet3 is in workbook2? (workbook1 and 2 are just example names).
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Run-time error 9: Subscript out of Range

    As suggested by Arlette, you are using the 'Worksheets' object without any reference to which workbook the object relates to, hence Excel will by default use the workbook that has the focus on that specific moment in time.

    you could use:

    Please Login or Register  to view this content.
    to ensure that Excel always looks for SHeet3 in the same workbook as where the code is running.
    If you like my contribution click the star icon!

  4. #4
    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

    or your code is in the Thisworkbook module of a workbook that doesn't contain a Sheet3 in which case the code always refers to the workbook containing the code no matter which workbook is active
    Josie

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

+ 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