+ Reply to Thread
Results 1 to 3 of 3

Closing non-active workbook

  1. #1
    Registered User
    Join Date
    05-31-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Closing non-active workbook

    Hi,

    I am not a vba excel. Below is the code that I am currently working on. It's pretty basic.
    The macro copies data from one file which is referenced by "" & Range("O1").Value & "" and pastes it into the active workbook. The problem that I am facing is that I do not know how to close the workbook that is being copied from. Any ideas?

    Thanks in advance.
    Please Login or Register  to view this content.
    Last edited by patelh9; 07-18-2010 at 08:54 AM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Closing non-active workbook

    Hello patelh9,

    You need to assign the other workbook to an object variable like you did with the ActiveWorkbook. Here is an example...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Closing non-active workbook

    Why the illegal *** in your code?
    But you might do something like this.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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