+ Reply to Thread
Results 1 to 22 of 22

Import data from several files into one sheet, special case

  1. #1
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Smile Import data from several files into one sheet, special case

    Hello,

    I read a lot of theads about data gathering from different files but my case is a bit different and I would appriciate your help for this case.


    we i have several exel files, and i want to copy information from second sheet with name DATA to one master file on sheet with same name.


    for exapmle

    George.xls information from DATA SHEET
    Nick.xls information from DATA SHEET
    John.xls information from DATA SHEET

    to one Master workbooks Data sheet

    files are located in one folder.

    range is from A7 to T7 and until A3000 and T3000

    operation to do is copy, paste special in master file.

    I am quite newbie in VBA and please please don't judge me much

    Thanks before hand
    Last edited by Jay-Kay; 07-09-2012 at 05:38 AM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Welcome to the forum.

    I have a couple of questions for you -

    1. You said the range is from A7 to T7 until row 3000. Is the header in row 7 or row 8?
    2. Does the master file have the header or should the macro insert it?
    3. If you run the macro the 1st time and data gets populated, if you want to run the macro a 2nd time, should the data in the master file be cleared and fresh data input?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    Thanks for reply Arlette
    1. actual data starts from that range header and some other stuff is above
    2. master file has same structure, data should be copied on same rages A7 to T7
    3, it would be better if macro will clean up existing data and then import new data.


    Thanks again

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Try this code
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button.

  5. #5
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    Thanks,

    I tried but this error came out 1.jpg2.jpg

    I have no idea what to do

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Change this line in your code from
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    Also, ensure the headers are already present in your Master file. If you want the macro to input them for you, let me know.

  7. #7
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    sorry for asking

    but what do you mean by headers.


    I supposed it was jus names of coloumns of data for example

    name | last name | age | ets. |
    Last edited by Jay-Kay; 07-09-2012 at 07:46 AM.

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Yes..you are right.

  9. #9
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    now i have this error

    Set sourceBook = Workbooks(CurrentFileName)

    sorry for bothering you

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    What error are you getting?

  11. #11
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    macro gives up error and when Debug, line Set sourceBook = Workbooks(CurrentFileName) is marked yellow

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    What is the error showing up in the small box where the debug window is present?

    You can also attach a sample file that you are using, so i can troubleshoot it for you.

    To Attach a File:

    1. Click on Go Advanced.
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.

  13. #13
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    For example.

    sorry i cant send you the actual data


    but u can see what kind of action is needed

    to copy all data from data sheet from jack and nick to mater books data sheet
    Attached Files Attached Files

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Try this updated code. Put this code into the Master file.
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    still not working.


    it copied information only from one file and pasted it in wrong cell.



  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Have you copied the code to the master file in a standard module? I ran it at my end and it worked fine.

  17. #17
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    I did but no result. can u send me your files?

  18. #18
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Here is the master file with the macro and the output in the DATA tab.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    07-06-2012
    Location
    Tbilisi
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Import data from several files into one sheet, special case

    thanks a lot

  20. #20
    Registered User
    Join Date
    06-21-2012
    Location
    Istanbul, Turkey
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Import data from several files into one sheet, special case

    I copied into master.xls but I have taken "400" error. Also my path directory is C:\TEST replaced on codes.

    Thanks in advance

  21. #21
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Import data from several files into one sheet, special case

    Gazteknokrat,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  22. #22
    Registered User
    Join Date
    06-21-2012
    Location
    Istanbul, Turkey
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Import data from several files into one sheet, special case

    Works out, 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