+ Reply to Thread
Results 1 to 2 of 2

Copy data from several files and paste into a new file

  1. #1
    Registered User
    Join Date
    12-19-2016
    Location
    Munich, Germany
    MS-Off Ver
    2013
    Posts
    1

    Copy data from several files and paste into a new file

    Hello everybody!

    I have a VBA problem which is probably simple for you guys but I could not manage to create something that works. I used the search before but didn't find anything that specifically fits or solves my problem so I was hoping that you can help me. Let me explain what I need to do first:

    I have around 50 files in one folder. All files are the same (with different file names obviously). The files have the same structure, the same tabs, the same columns in the tabs. The only difference is the data stored within the tables in the tabs. Some have more rows than others and the values are different. Now I want to copy all rows in a specific tab that are marked with an "x" in column A and want them pasted in a new file so that the data from all 50 files is underneath each other in the new file.

    Example:

    I have Workbook1, Workbook2 and Workbook3. In each of these Workbooks, my data is stored in Sheet1. Now I want to copy rows 1 and 3 from Workbook1, row 2 from Workbook2 and rows 2 and 5 from Workbook3 into the new file underneath each other (because these are all the rows marked with "x" in column A), so that always the next empty row is used. In the end it should look like this:

    Workbook1, row1
    Workbook1, row3
    Workbook2, row2
    Workbook3, row2
    Workbook3, row5

    First I thought I can implement a macro in each of the Workbooks that opens the new file and then copy&pastes the data in the new file. However this did not work because my data in the new sheet always got overwritten when using this method with successive files. So my next idea was to create a macro in the new file that points to the Workbooks and imports the data from all the Workbooks. This did not work because all the Workbooks have macros due to which I need to manually click "ok" in two message boxes that appear when I open the files.

    In the end I don't mind whether I create the macro in the Workbooks or the new file, I just want to extract the "x" marked rows from each of the Workbooks into the new file underneath each other.

    I hope that the explanation of my problem is clear enough and that you can help me.

    Thank you very much in advance, your help is very much appreciated.

    Best,
    T.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy data from several files and paste into a new file

    Your second method is best. If you post your code for your working macro we can offer suggestions.

    Off the top of my head, near the very top of the macro you probably want to add this line of code to suppress 99% of all dialog boxes:
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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. VBA to open 2 JPEG files in MSPaint and copy File 1 and paste in File 2.
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2016, 01:31 PM
  2. Copy and Paste Data from files to Master File thru Macro
    By soumendu_bose in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2014, 05:48 AM
  3. [SOLVED] Need help! Macro to open sequentially named files, copy and paste data into a master file
    By derrickk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-05-2013, 03:35 PM
  4. Replies: 0
    Last Post: 04-13-2013, 10:45 AM
  5. Copy data from other files and paste in current file ----really need assistance
    By aetedford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2013, 05:37 PM
  6. [SOLVED] Need a macro to copy paste data from multiple files into a file as a database
    By etandogan in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-13-2012, 02:14 AM
  7. Replies: 1
    Last Post: 09-22-2010, 11:00 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