+ Reply to Thread
Results 1 to 3 of 3

Activate another open workbook and sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Activate another open workbook and sheet

    I have a main spreadsheet that opens another spreadsheet and copies that second workbooks directory to a cell on the main page. I am trying to be on the main workbook and activate a certain sheet on the second workbook, which is determined by a data validation list of the sheet names. I want to have the sheet be selected, and the user clicks a button and it will activate the directory in D6 and the sheet in D8 of this picture.

    I saw somewhere that said something like the code below would work, but i get an error on the Workbook activation line. (error: Run-time error '9': Subscript out of range)

      Dim Entry As String
        Dim Filepath As String
    
    
        Filepath = Range("D6").Value
        Entry = Range("D8").Value
    
    
        Workbooks(Filepath).Activate
         Worksheets(Entry).Activate
    Do i need to be using the Workbook object or will this work with strings?
    Last edited by DFrank231; 01-15-2013 at 09:34 AM.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Activate another open workbook and sheet

    Not path but name, not workbook but Windows
    Sub a()
     Dim Entry As String
        Dim Filepath As String
        Filname = "Cartel1.xlsx" 'Range("D6").Value
        Entry = "Sheet1" 'Range("D8").Value
        Windows(Filname).Activate
         Worksheets(Entry).Activate
    End Sub
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    11-17-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Activate another open workbook and sheet

    Dim Filename, Entry As String
    Filename = Range("D6").Value
    Entry = Range("D8").Value
    Windows(Filename).Activate
    Worksheets(Entry).Activate
    This is what i did based on your response and i am getting the same error. Am i missing something here?


    Windows(Filename).Activate
    (error: Run-time error '9': Subscript out of range)

+ 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