+ Reply to Thread
Results 1 to 26 of 26

Copy data from closed workbook into the new current workbook by value.

  1. #1
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Copy data from closed workbook into the new current workbook by value.

    Hi guys,

    I want to make macro that will allow user to copy data by value (results of the formulas (values) and not formulas it self) from one workbook to another.
    Source workbook should remain closed when coping data from it into the new, opened excel workbook.

    Can you help me get the code for this?

    P.S. Source workgroup contains more the one worksheet so I need to be able to choose from what worksheet Im coping the data by name for example.

    Thank you in advance.
    Last edited by Dolke; 01-15-2018 at 04:18 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy data from closed workbook into the new current workbook by value.

    What kind of help are you looking for?

  3. #3
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Im looking for a help to make a marco that does this.

    I have found a lot of similar solutions for example this:

    Please Login or Register  to view this content.
    So basically can you help me modify/fix this code to get the functionality that Im describing?

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy data from closed workbook into the new current workbook by value.

    You need to supply details.

  5. #5
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Im not sure what other details would you need but ok let me explain once more.

    I have one workbook (I accidentally called it workgroup in previous posts) and that excel workbook contains several sheets. Each sheet is full of formulas.

    Lets call this workbook source.xlsx

    Then Im working on something else and for that I open new blank workbook (lets name it destination.xlsx) and I want to copy entire sheet (one of them) from source.xlsx to destination.xlsx without opening source.xlsx.
    Source xlsx is actually file located somewhere on our local area network and its usually located on another network PC

    Also when copying data from source to destination I only need values. So basically I need results of the formulas in the sheet that Im coping and not copy of the formulas it self.

    I hope this clears what Im trying to get.

    If you need more info please let me know.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Copy data from closed workbook into the new current workbook by value.

    You can use the macro recorder to do this. Once you get the code you can post back to get the code more efficient.

    The workbooks have to be opened in order to copy and paste.

    When you are in the macro recorder.
    Start from the source workbook.
    Open the destination workbook.
    Copy from the source workbook, pastespecial in the destination workbook, save and close the destination workbook

    Post back with the code.

  7. #7
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Im not sure how can I record macro and copy entire spreadsheet as a value and not formulas and also how can I copy the content with macro recorder and not to open source file?

    Also

    The workbooks have to be opened in order to copy and paste.
    I believe this is not true. You can copy content without opening a file.

    There are some soruces here:
    https://stackoverflow.com/questions/...aster-workbook
    Last edited by Dolke; 01-12-2018 at 08:00 AM.

  8. #8
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Copy data from closed workbook into the new current workbook by value.

    You can copy content without opening a file.
    Oh yes you can but what is the advantage?

    Well anyhow John Walkenbach describes one way to read data from closed files, see link.

    http://spreadsheetpage.com/index.php...a_closed_file/

    Alf

  9. #9
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Copy data from closed workbook into the new current workbook by value.

    Also you can use PowerQuery add-in for Ex2010 Pro Plus where you can select from closed workbook what you want to "import" and show in destination file.

  10. #10
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Quote Originally Posted by Alf View Post
    Oh yes you can but what is the advantage?

    Well anyhow John Walkenbach describes one way to read data from closed files, see link.

    http://spreadsheetpage.com/index.php...a_closed_file/

    Alf
    Advantage is the folowing:

    I have file (source file) somewhere on one PC in the LAN.

    There there is a spreadsheet with lot of formulas. I dont want to navigate all the time and open the file and copy/paste the results of that formulas into the new working workbook.
    Instrad I can click one button and get those results over the LAN instantly and not copy the formulas but values only.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    Adjust sheet name & column header.
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Thank you jindon for the code.

    Can you please clarify why do I need column header?

    I want to copy entire sheet not just one column.

    Also Im not sure what do I need to put for column header...
    Last edited by Dolke; 01-12-2018 at 09:38 AM.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    Isn't your code just importing col.B?

    If you want all
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    No, not only column B,

    I want to import everything from specific spreadsheet...

    So if source file has 5 sheets I want to be able to select specific sheet (by name) and get all data by value from that sheet.

    Let me check the new code...

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    Quote Originally Posted by Dolke View Post
    No, not only column B,
    Yes, it is.
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Sir,

    It seems that this code is working.

    Im testing it now and I will let you know if all is good.

    Thank you and I will need a donate for a beer, coffee or what ever you drink.

    I might need some small extension but as I said testing it now and I will let you know

  17. #17
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    It seems that its working...

    Once small thing though.

    Is there a way to set this macro to run automatically when file containing it opens so it can grab fresh data from that source file each time?

    Thanks

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    Paste the code on to ThisWorkbook code module
    Please Login or Register  to view this content.
    If you change the procedure name from"test" to something else, make sure you also change the bold part.

  19. #19
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Im getting this:

    http://prntscr.com/hzhm85

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    Can you upload a workbook that you get error?

  21. #21
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Its just blank workbook with macro...

    As source Im using one excel file that I have on one PC in the LAN.

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    I don't get error, so I'm asking.

  23. #23
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Let me try one more time to see whats going on.

    Thank you.

  24. #24
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    Dolke

    If you are getting such error, most probably "test" procedure is placed in sheet code module.

    If so, 2 options.

    1) Move "test" procedure to a standard module.
    While you are in VBE, [Insert] - [Module] and move the code onto that module.
    The delete the code in sheet code module.

    2) Change ThisWorkbook code to
    Please Login or Register  to view this content.
    Where "Sheet1" is the name of the sheet in which the code is placed.

  25. #25
    Registered User
    Join Date
    01-27-2011
    Location
    Novi Sad, Serbia
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Copy data from closed workbook into the new current workbook by value.

    Hi guys,

    Thank you all for taking interest in this topic.

    Special thanks goes to Jindon for helping with the code. Code works like a charm!

    Sir, I would like to make a small donation and buy you a beer so if you have paypal please let me know via PM.

    I will mark this thread as SOLVED.

    Cheers
    Dean

  26. #26
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Copy data from closed workbook into the new current workbook by value.

    OK, that's good.

    Your feedback and "Thanks" made me happy already. Thanks anyway.

+ 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] VBA Macro pull a certain cell in closed workbook and copy/paste into current workbook
    By Hoover5896 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2017, 01:36 AM
  2. [SOLVED] Get data from Closed workbook and paste in current Workbook
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-08-2015, 02:45 PM
  3. [SOLVED] Copy a Worksheet from a Closed Workbook to the Current Opened Workbook
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-28-2014, 12:55 PM
  4. Replies: 0
    Last Post: 03-27-2014, 12:38 PM
  5. VBA code for copy data from closed workbook to "Data " sheet of current workbook
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-13-2014, 02:23 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. Copy Data from Closed workbook (bbb.xls) to Open workbook (aaa.xls) (Part 2)
    By alexnkc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2013, 02:06 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