+ Reply to Thread
Results 1 to 7 of 7

HELP: Copy Data from Multiple CSV files to an output xls file

  1. #1
    Registered User
    Join Date
    01-31-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    HELP: Copy Data from Multiple CSV files to an output xls file

    Hi All,

    Would like to seek your help on creating a Macro that will search for the filename listed under column A and copy values from that file (under Column C) to a new excel sheet as named under Column B.

    Example:

    These columns are under Index Workbook. All of the files under Column A are saved on one folder in desktop. So if the file opened from the folder is named as BOM Gen A English.csv or BOM Gen B English.csv, it copies the data on those sheets under Column C to a new workbook named as BOM Res1 English.xls and then adds the values of the column information pasted.

    Column A Column B
    BOM Gen A English.csv BOM Res1 English.xls
    BOM Gen B English.csv BOM Res1 English.xls
    BOM Gen A French.csv BOM Res1 French.xls
    BOM Gen B French.csv BOM Res1 French.xls
    CAN TA A Chinese.csv CAN TA Chinese.xls
    CAN TA B Chinese.csv CAN TA Chinese.xls

    I have attached the sample files needed.

    Would really appreciate your help on this.

    Thanks so much in advance, excel vba macro Gods.

    Cheers,
    Anata
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: HELP: Copy Data from Multiple CSV files to an output xls file

    Hi..

    it copies the data on those sheets under Column C to a new workbook named as BOM Res1 English.xls and then adds the values of the column information pasted.
    So you want all data in Column C of the Source File to be copied to the newly created sheet (name taken from Column B of the Index file)..?

    If so.. where do you want the data copied to.. which column ?

  3. #3
    Registered User
    Join Date
    01-31-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: HELP: Copy Data from Multiple CSV files to an output xls file

    Hi Apo,

    Thank you for your reply. Output data to be copied to column A of the new worksheet.

    Thanks,
    Anata

  4. #4
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: HELP: Copy Data from Multiple CSV files to an output xls file

    Hi.. Try this..

    To test... Put the Index.xlsm and all the csv files in the following directory:
    C:\Archive\

    Change that if you like in the code to suit..

    Also note: I had to save the files as xlsx files.. as xls files have a maximum row size limit of 65536 rows..

    If multiple CSV files are linked to 1 xlsx file.. the data is appended to the bottom of the last value in column A..

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by apo; 03-28-2014 at 03:49 AM.

  5. #5
    Registered User
    Join Date
    01-31-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: HELP: Copy Data from Multiple CSV files to an output xls file

    Hi apo. Thank you for the codes. However it does not append the data to the bottom of the last value in column a, it overwrites the entire file instead. I think it is because the workbooks.add and save as overwrites the first saved file before the loop. Help pls?

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: HELP: Copy Data from Multiple CSV files to an output xls file

    mm.. changed some filepath values.. try this..


    I get this:

    In the resulting file.. Bom Res1English.csv.xls.... i get 154332 rows.. meaning that both the BOM General Enquiries English.csv & BOM New Reservations English.csv files have been added to a combined row total of 154332... is that not what you get when you run it??


    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-31-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: HELP: Copy Data from Multiple CSV files to an output xls file

    Thank you so much for the codes, worked perfectly!

+ 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. [SOLVED] How to Extract Data from Multiple Files in Same Folder and Copy Data to One File
    By champ052005 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 01:25 PM
  2. Creating Multiple Output Files from a Master File and updating data between workbooks
    By EXCEL0429 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2013, 11:54 AM
  3. [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
  4. Open a file and copy data into multiple files
    By ncduke in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2010, 09:39 AM
  5. [SOLVED] How do I pull data from multiple files and copy into one file
    By JT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2005, 03:06 PM

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