+ Reply to Thread
Results 1 to 4 of 4

closing only one workbook when multiple open

  1. #1
    Registered User
    Join Date
    12-16-2007
    Location
    Ohio
    Posts
    3

    closing only one workbook when multiple open

    Hi all -
    I'm new to the forum and to Excel VBA. I'm hoping to learn more about VBA and I'm looking for some help.

    I'm trying to write a macro that will copy a sheet from one excel workbook (the CopyFrom workbook) and copy it into a another workbook (CopyTo) that will be a compilation of these other worksheets. I've got the macro to copy the sheet ok (after finding code on the site) but a couple of things are happening that need some advice with -

    1. I'm opening the CopyFrom workbook with workbooks.open, so I can see it opening. I'm using workbooks.worksheet.copy to copy the sheet. Is there a workbooks command that can be used instead of .open?

    2. Because I'm using workbooks.open, the CopyFrom workbook remains open. How do I close it? It isn't the activeworkbook so the close method closes the CopyTo workbook. The simple thing to do is to set the CopyFrom workbook to the activeworkbook and then close it, but I don't know how to do it. Can someone help with the syntax / method??

    I apologize for the simplicity of these questions. I have a VBA book coming to help with the syntax and methods.

    Any help is greatly appreciated.

    Thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Why not create references to the workbook(s) involved?

    For example:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    You could now use this to close the workbook that you opened.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It would be better to post what code you have, remember to use Code tags. However, you do not need to actvate workbooks. You need something like this:

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    12-16-2007
    Location
    Ohio
    Posts
    3
    Thanks for the help -

    Its been a while since I've done this level of programming (last big project was done in Turbo Pascal in a DOS environment on an IBM AT). I'm hoping the two books I ordered will help get the rust off and familiarize myself with all the syntax.

    Thanks again for the help.

    Mark

+ 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