+ Reply to Thread
Results 1 to 14 of 14

Need a macro to copy paste data from multiple files into a file as a database

  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Need a macro to copy paste data from multiple files into a file as a database

    Urgently I need a macro to copy data from multiple files, same sheet and cells (file names; 01 Report, 02 Report, 03 Report...; sheet Direct Personel; cells A3:D59) into a new file as a database.
    Files are located in the same folder.

    Thanks in advance

  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: Need a macro to copy paste data from multiple files into a file as a database

    Do you want them pasted side by side - one under the other????
    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
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Quote Originally Posted by xladept View Post
    Do you want them pasted side by side - one under the other????
    Yes I want them pasted one under the other.

  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: Need a macro to copy paste data from multiple files into a file as a database

    Try this: (it's called "running the directory")

    Please Login or Register  to view this content.
    Last edited by xladept; 12-09-2012 at 08:49 PM.

  5. #5
    Registered User
    Join Date
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Unfortunately it doesnt work. I`m new to the world of Macro so I couldnt understand what is the problem.

    Let me explain my need in detail. In a folder, I have many reports (excel files) named; 201201 Report.xlsx, 201202 Report.xlsx, 201203 Report.xlsx, 201204 Report.xlsx... These workbooks have many sheets.

    I need copy data from these workbooks` "A1:D500" cells in "Direct Pers" sheet and paste as a database into a new workbook (pasted one under the other).

    Thanks in advance.
    Last edited by etandogan; 12-10-2012 at 01:22 AM.

  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: Need a macro to copy paste data from multiple files into a file as a database

    Hi etandogan,

    The program works for me on my system - I know that the backslash at the end of the path is critical -if your configuration includes the backslash in the path then it shouldn't be appended. One way to discover whether the configuration is copacetic to my code is to single step through the program (by hitting F8), and see whether the:
    Please Login or Register  to view this content.
    yields a result rather than a null "".

    You can change the names and range particulars as well as the
    Please Login or Register  to view this content.
    to conform to your actual situation.

    And, one other thing - do you realize that the program must be in a macro-enabled Workbook (extension - .xlsm)

  7. #7
    Registered User
    Join Date
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Hi xladept,

    It is working without any error. Perfect work, I cant thank you enough

    The only timekeeper count is that while each report is opening, excel ask whether update or dont update it. I select "not update" every time. Is it possible to stop it. If not, no problem, it is so succesfull as it stands.

    Again thank you ever so much.

  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: Need a macro to copy paste data from multiple files into a file as a database

    Hi etandogan, try this (new code in red)


    Please Login or Register  to view this content.
    And - You're welcome!

  9. #9
    Registered User
    Join Date
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Sorry but still ask while opening

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

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Well then - maybe:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Run time error '9'

    Subscript out of range

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

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Hi etandogan,

    Here's a change that should work - that I should have thought of sooner - just change the open statement:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-08-2012
    Location
    Baku
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Need a macro to copy paste data from multiple files into a file as a database

    Perfect work !!!!!

    Thanks again. This thread is completely SOLVED

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

    Re: Need a macro to copy paste data from multiple files into a file as a database

    You're welcome again - it always seems so easy once it's done!

+ 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