+ Reply to Thread
Results 1 to 3 of 3

Error when opening workbook with variable name in VBA: Subscript Out of Range 9

  1. #1
    Registered User
    Join Date
    07-16-2014
    Location
    Seattle, WA
    MS-Off Ver
    Office 365
    Posts
    67

    Error when opening workbook with variable name in VBA: Subscript Out of Range 9

    I have a folder with 2 workbooks. One with macros named VBAHelp_11111.xlsm and one without macros named 11111.xls. The code of the macro enabled workbook *should* 1. ask the user for a run number 2. Use that run number to open the excel file with that run number as a name

    Ex. run = 11111
    Program should open 11111.xls

    Since they are in the same folder, I use a variable path to assign the location. However, when I try to open the folder using

    Please Login or Register  to view this content.
    I get the subscript out of range error. I have even added a sub function that checks to make sure all of the workbook names match but still no luck. Please help!

    Here is the full code, and I have attached the files that in my desktop, are the only 2 files in a folder titled TPR_Help.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    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: Error when opening workbook with variable name in VBA: Subscript Out of Range 9

    Wrong syntax.

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    07-16-2014
    Location
    Seattle, WA
    MS-Off Ver
    Office 365
    Posts
    67

    Re: Error when opening workbook with variable name in VBA: Subscript Out of Range 9

    @shg Thank you for the quick reply! That solved it perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Subscript Out of Range Error when moving worksheet to another workbook
    By ozhunter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2015, 12:33 AM
  2. Subscript out of range error on PasteSpecial to convert all in a workbook to values
    By m3atball in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-08-2015, 02:34 PM
  3. [SOLVED] Closing a Workbook from another workbook: Workbooks.close error: Subscript out of range
    By Coreyusa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-14-2013, 06:45 PM
  4. [SOLVED] Copy row contaning matching value to another workbook - Subscript out of range error
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-04-2013, 12:55 PM
  5. [SOLVED] Subscript out of range (error 9) When setting active workbook
    By DotWFM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2013, 04:00 PM
  6. [SOLVED] Select Sheets based on variable array -ERROR 9 Subscript out of range
    By airmiles in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-19-2012, 07:28 PM
  7. Help!! - Subscript Out of Range - Error while calling a workbook frmm another sheet..
    By ragavendraph in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-29-2012, 12:53 PM

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