+ Reply to Thread
Results 1 to 4 of 4

run-time error '9' subscript out of range 2007 excel

  1. #1
    Registered User
    Join Date
    10-18-2012
    Location
    houston
    MS-Off Ver
    Excel 2003
    Posts
    2

    run-time error '9' subscript out of range 2007 excel

    Hi I am using Microsoft Excel 2007.

    I get the 'Run Time Error '9' Subscript out of range' when running the macro that I use everyday. This macro formats a report I create everyday and it is available for other users so the macro is on a shared drive and everyone can use it. The weird thing is that I wasthe only one receiving this messsage. if I run the macro from other computer it was working smoothly. I was only experiencing this problem on this specific work station. I was running it from other stations but now it gives me the same error on every computer.



    If I click Debug it highlights the following line in my macro:



    Windows(MyFile).Activate


    Help would be greatly appreciated!

    Thanks



    I am copying the code of that module:


    Please Login or Register  to view this content.
    Last edited by rulo777; 10-30-2012 at 09:27 AM.

  2. #2
    Forum Contributor stojko89's Avatar
    Join Date
    05-18-2009
    Location
    Maribor, Slovenia
    MS-Off Ver
    MS Office 365
    Posts
    913

    Re: run-time error '9' subscript out of range 2007 excel

    My god....please use CODE tags, Edit your post and put the code in CODE TAGS! so the code will be readable

  3. #3
    Registered User
    Join Date
    10-18-2012
    Location
    houston
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: run-time error '9' subscript out of range 2007 excel

    Done, does that works for you?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: run-time error '9' subscript out of range 2007 excel

    You probably could Google that error message and get the basis of the problem pretty quickly. "Subscript out of range" errors invariable mean: "Some object (sheet, workbook, named range) that you gave me the name for to use.... Excel can't find that object."

    The line of code supports that. MyFile is a string you got from J3. What exactly is that string? If even 1 character varies from the exact name of an already open workbook, it won't work.

    Also, if the name is exact, is it already open? I'd recommend you set a workbook variable instead of a string, because then you can address the workbook from then on without using the real name again, just the wb variable.

    Also, once you have the wb variable, you don't have to "activate" or "select" the objects anymore, you can just send data directly to the objects.

    Here's as much of that macro as I could decipher to get you started rewriting it addressing those objects directly:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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