+ Reply to Thread
Results 1 to 4 of 4

Macro/VB code to open a file specified in cell

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    New Castle, DE
    MS-Off Ver
    Excel 2007
    Posts
    65

    Macro/VB code to open a file specified in cell

    Hello,

    I've been looking for a way to add a code to one of my macros that will open a file that is specified in cell I1 for five tabs. Each tab pertains to an account and each cell in each tab already has the fille path name in cell I1. Can anyone help me add a code to open the file and copy the tab to the opened file?

    The current code is as follows:
    Please Login or Register  to view this content.

    Thank you,
    ~Miriam

  2. #2
    Registered User
    Join Date
    09-02-2009
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Macro/VB code to open a file specified in cell

    Seems like you have the file opening alright.

    After that you should set a workbook variable to hold the reference to the opened workbook and then copy the source worksheet into that file. A possible problem is that any active formulae on the source worksheet which refer to other tabs in its original parent workbook will continue to refer to the original workbook (i.e. the two workbooks will be linked). This isn't an issue if you don't have any off-sheet formula references.

    Please Login or Register  to view this content.
    Will copy your 944300 sheet after the last sheet of target file strFileName which you opened in the last line of your posted code. Repeat for the others.

    You'll probably want to add
    Please Login or Register  to view this content.
    each time to close your target workbook saving changes after each copy, assuming you don't want them left open.

  3. #3
    Registered User
    Join Date
    12-03-2012
    Location
    New Castle, DE
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Macro/VB code to open a file specified in cell

    Sorry, the macro i have is not really opening the file that I have in indicated in cell I1. The last two rows of my macro is not really working properly, which I assume I have written it incorrcetly, but not really certain.

    strFName = 944300.Range("I1").Value
    Workbooks.Open Filename:=strFName


    Thank you,
    ~Miriam

  4. #4
    Registered User
    Join Date
    12-03-2012
    Location
    New Castle, DE
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Macro/VB code to open a file specified in cell

    I was actually able to solve this problem ... on to the next problem.

+ 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