Results 1 to 4 of 4

VBA in Excel: define file to open (I retrieve data from 2 Excel files)

Threaded View

  1. #1
    Registered User
    Join Date
    02-13-2012
    Location
    NYC
    MS-Off Ver
    Excel 2003
    Posts
    39

    VBA in Excel: define file to open (I retrieve data from 2 Excel files)

    Hello,

    I have 2 Excel files open, file (A) is a data source file and file (B) is a file with various sheets being created with VBA.
    My VBA needs to be clear which of both files it refers to when reading data, and I believe that is my problem.

    I have the following written:


    DataSourceFile = Range("LastFileEdited")
    Set W2bk = Workbooks (DataSourceFile)        'I receive error 9: suscript out of range
    Workbooks(W2bk).Open

    How should I correct my VBA so that it opens the specified file? And if the file is already open, to select it?
    Thank you for your help.
    Last edited by Cutter; 08-14-2012 at 07:26 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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