+ Reply to Thread
Results 1 to 13 of 13

Macro to copy data from two workbook to another where all workbooks are open

  1. #1
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Macro to copy data from two workbook to another where all workbooks are open

    Hi,

    I have 3 workbooks open. 1 is my working file and I name it as "Final[date].xlsm". The other 2 files are my source files which are also open are named as source1.xlsx and source2.xlsx. Both the source files has only one tab/sheet as "Sheet1". My objective is to bring the contents of the source file to my working file in 2 different sheets. all the contents in Sheet1 of "Source1.xlsx" should be paste.values only to the "Final[date].xlsm" with a sheet name "BankDetails". This will enable the user also to replace the old data in "BankDetails" tab. The "source2.xlsx" sheet1 has a different situation. I need to copy only the cells with values, not the entire cells, because it has to be pasted (values only) to range C2:L. I have formulas in the other columns before C and after L.

    Take note that my working file name is changing every based on the date while my source file has always same file name.

    Kindly help.

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Please post sample workbooks.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  3. #3
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Hi Guys, I attached sample workbooks. BTW, Source2.xlsx content should go to "Premium" tab.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Try this (you'll have to change the file paths):
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Hi k64. The problem (I think) on your suggested code is that my source file is not always on the same folder or drive. I cannot change every now and then my code. Is there something that it identifies the workbook that is open with the same file name?

    Thanks.

  6. #6
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Yes, you can just put
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and copy that formula. That may work if your situation is simple. It doesn't allow you to do more complex things.

  7. #7
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy data from two workbook to another where all workbooks are open

    I'm sorry, I am really a beginner in VBA. How can I put that formula to the codes you provided above.

  8. #8
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy data from two workbook to another where all workbooks are open

    My clarification follow up might not clear enough. What I was trying to say is that, the source file is not always in the C drive. Sometimes, it will be in a server or attachment to an email. The file name is constant though. The user should open the 2 source file and grab the data in it.

  9. #9
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro to copy data from two workbook to another where all workbooks are open

    If you put in A1 this formula, it won't work. But then if you open source 1, it will.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Also, if the workbooks will always be opened in the same order and there won't be other workbooks open, I can modify my code.

  10. #10
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy data from two workbook to another where all workbooks are open

    I tried pasting the above formula and when I open Source1.xlsx, the cell A1 is updated. That means, I need to put this formula to all the cells in the sheet. I am not comfortable on this because if the user replaces the previous source file, data innthe current workbook will change. I need the data to be fixed in the destination tabs. something that should copy and paste values only.

    with regards to the manner on how the source files are opened, I can asked the user to open the source file one at a time, if this can help? Because I cannot guarantee the sequence in opening the file or opening the file on the same order.

    Appreciate your help further.

    Thanks.

  11. #11
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Let me know if this works
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-11-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy data from two workbook to another where all workbooks are open

    Whew! I love it! it works well... Thanks a lot.

  13. #13
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro to copy data from two workbook to another where all workbooks are open

    You're welcome. Glad I could help

+ 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. Macro to open workbooks, process data, save copy as a csv
    By jdgwebdev in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-13-2013, 01:09 PM
  2. [SOLVED] Open Multiple Workbooks, Record names, Copy paste to Active Workbook, Close the Workbooks
    By vba_madness in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-24-2013, 06:09 AM
  3. Copy Data From Multiple Open Workbooks to Another Workbook with Separate Worksheets
    By lupitenis in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2012, 05:36 PM
  4. [SOLVED] Macro to copy data from open workbook to next open line of new workbook
    By nhtodd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2012, 09:42 PM
  5. Macro to copy data from other workbook - let user choose which open workbook
    By ssu95bm in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-12-2011, 11:17 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