+ Reply to Thread
Results 1 to 5 of 5

vba code to copy a specific sheet from a closed workbook to the active workbook

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    vba code to copy a specific sheet from a closed workbook to the active workbook

    I have an active workbook with several sheets

    I am looking a vba code that copy a specific sheet called "workings" from a closed workbook of the following path"c:\\sample\INTERFORMAT.xlsx" to the active last sheet in the open workbook.

    That is sheet named "workings" should be last sheet in the active workbook but the INTERFORMAT.xlsx should always remain closed

    Thanks if anyone can assist

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: vba code to copy a specific sheet from a closed workbook to the active workbook

    Why is it important to you that the source file remain closed?

    I dont want to say it cant be done, as a matter of fact I know it could be done...its just extremely difficult and not worth the effort. Generally when doing this you open the source file, copy what you need and close it in the macro. The end user never has to see the file or know its been open. If I know all I need is to get info from it I even open it as read-only so my code doesn't accidentally change the source file.

    The only way I can think of you will accomplish this without opening the file is to (always in a copy, not the original file) change it to a zip, extract the xml representing the sheet and additional information needed, incorporate it into your own file: generally destination also needs to be closed to directly insert the xml parts/manipulate the underlying xml) or you parse the underlying xml from the source and process it into a new sheet you create. If this sounds complicated and way overboard...thats because it would be.

    Once we know why opening the source isnt an option (or maybe it really is) we can more directly answer your question

  3. #3
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: vba code to copy a specific sheet from a closed workbook to the active workbook

    The file need to be closed because it is a template sheet with formula, I have some users who messed the template file and it was a headache .

    So this is why it is important the file remain closed as it is will be triggered by a macro.

  4. #4
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: vba code to copy a specific sheet from a closed workbook to the active workbook

    That may be a reason to ask people not to open the file themselves, but for a macro thats not really a valid reason to not open it via the macro, process it and then close it.

    As I mentioned, I typically open a read-only copy of the file so that any potential changes cant be saved to it. Your users will never know its been opened and closed. There are multiple ways to accomplish opening and closing the file without displaying it to the user while the macro runs. You can use screen updating or open a new instance of Excel and setting its visible property to false then opening the file within the new instance.

  5. #5
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: vba code to copy a specific sheet from a closed workbook to the active workbook

    Here is the code that is working smartly

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] macro to copy active sheet to a closed workbook in a specified directory
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-30-2017, 04:43 AM
  2. [SOLVED] vba copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2017, 01:33 PM
  3. [SOLVED] copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2017, 10:26 PM
  4. vba copy specific sheet from closed workbook to active workbook
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2017, 02:34 PM
  5. copy of sheet from specific workbook to active workbook
    By prabhuduraraj09 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-06-2014, 07:31 AM
  6. [SOLVED] Code to copy data from a closed workbook and paste in active workbook using named range.
    By paullie1912 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2014, 02:38 AM
  7. Run Macro in closed workbook and copy specific coloumn in active workbook
    By shiva_reshs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2013, 03:43 AM

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