+ Reply to Thread
Results 1 to 11 of 11

Copy Content of 3 Excel File into another Workbook

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2013
    Posts
    27

    Copy Content of 3 Excel File into another Workbook

    Hi All,
    I have 4 excel files that I generate each month. Here are the names:
    short_aum.xlsx
    shortu_aum.xlsx
    long_aum.xlsx
    longu_aum.xlsx

    They are always kept in the same folder: S:\CRetrum\Composite\BuildsforMacro

    I would like to have them copy to the following tab in this spreadsheet Composite_Return_Report_TEMPLATE.xlsm
    Short
    Short Under
    Traditional
    Traditional Under

    I am assuming the macro would reside in the Composite_Return_Report_TEMPLATE.xlsm file, but am not sure if the others can be closed (that would be ideal). I also am not sure if I can keep the remaining tabs left along in this workbook and simply repaste over these tabs.

    Any guidance is appreciated!
    Thanks all!
    Kerry

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Content of 3 Excel File into another Workbook

    Hi Kerry,

    Do the generated files all have just one tab and is it named "Sheet1" or must we use Sheets(1)?

    And you can clear the tabs and then just repaste over them.

    It's not very fancy but see if this does what you want:

    Please Login or Register  to view this content.
    Last edited by xladept; 10-04-2013 at 02:31 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2013
    Posts
    27

    Re: Copy Content of 3 Excel File into another Workbook

    Thanks so much for the speedy reply.

    "Do the generated files all have just one tab and is it named "Sheet1" or must we use Sheets(1)?"
    YES, each excel file only has one tab name in it and it is Sheet1.

    I tried running this but am assuming I need to add path information somewhere to let it know where to pull the files from?
    Also do I add the file extension to the end of each one? I am getting a debug at this line:
    Set wb = Workbooks("Composite_Return_Report_TEMPLATE")

    Thanks

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Content of 3 Excel File into another Workbook

    Hi Kerry,

    I was totally frustrated yesterday, trying to get back to you - the code above should have worked if you had had each file open - this code will open them, but I hope the names are unique and, you mentioned that the code would reside in the template file so here's my next installment:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2013
    Posts
    27

    Re: Copy Content of 3 Excel File into another Workbook

    Thanks again for your hard work - sorry for your frustration Friday!

    You are right, none of the spreadsheets will be open (or at least that was my idea) or else the user might as well just open each and copy them over. So what you have done is great here.

    However, getting frustrated myself like I am missing something! It all looks like a simple macro, but now when I run it, I still get a debug at this line:
    Set ws = Workbooks("short_aum").Sheets(1) "Debug: Script out of Range"

    It DOES open the short_aum spreadsheet up which is positive. But then sits there and does not copy it over?

    Thanks!
    Kerry

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Content of 3 Excel File into another Workbook

    Hi Kerry,

    Try replacing all the
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-21-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2013
    Posts
    27

    Re: Copy Content of 3 Excel File into another Workbook

    That doesn't work either. Still debug on that line.

    I might approach this from another way. Thanks for your efforts.

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Content of 3 Excel File into another Workbook

    Hi Kerry, - Maybe

    Make all the Set ws statements into
    Please Login or Register  to view this content.
    and then
    Please Login or Register  to view this content.

  9. #9
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Content of 3 Excel File into another Workbook

    Hi Kerry,

    Another attempt:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-21-2012
    Location
    Illinois
    MS-Off Ver
    Excel 2013
    Posts
    27

    Re: Copy Content of 3 Excel File into another Workbook

    Worked like a charm! Great job! Thanks for all your help!

    This is what I settled on...
    (FYI to others looking at this, it seemed key to 'close' each spreadsheet after copying from it, or else I got an error about how much I had on the clipboard.)


    Please Login or Register  to view this content.

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy Content of 3 Excel File into another Workbook

    Hi Kerry,

    Terrific! Glad you got it to work (it didn't work with the close in the subroutine??)

+ 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. Search content of *.txt file and copy certain words of a sentence to a cell
    By Joe photo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2013, 12:57 AM
  2. Match string and copy line content to other file
    By zaibon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-02-2013, 11:26 AM
  3. Copy content of one workbook to another workbook without opening both the file
    By Mansoor_naz2002 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-12-2011, 11:39 PM
  4. Locate and copy content of an open .xls file
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-09-2010, 01:02 PM
  5. Replies: 1
    Last Post: 10-17-2005, 04:05 AM

Tags for this Thread

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