+ Reply to Thread
Results 1 to 7 of 7

code to copy first rows and sheet titles from separate csv files into summary sheet

  1. #1
    Registered User
    Join Date
    05-07-2017
    Location
    Australia
    MS-Off Ver
    office 2013
    Posts
    3

    code to copy first rows and sheet titles from separate csv files into summary sheet

    Dear experts,

    I have a number of csv files, in each of these only the first row is filled with relevant content in cells A1:I1. I want to batch import the content of column A-I in row 1 from each of these files into one summary sheet so that the summary sheet has as many rows as there are files imported. In addition to that I would like the sheet names of the imported files to be added in the first column of the summary sheet.

    Do the files to import need to all be in the same folder or can they be in subfolders, too?

    I have experimented with bits of code I found on the net but ended up getting errors. I should probably add that I don't have any previous experience with VB and macros, just with standard excel.

    Your help would be much appreciated, thank you!

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: code to copy first rows and sheet titles from separate csv files into summary sheet


    Hi !

    It's easier for a VBA beginner to have files within an unique folder !
    For subfolders, use Dir VBA function in a recursive way …

    You can start your code just by activating Macro recorder and operating manually.

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

    Re: code to copy first rows and sheet titles from separate csv files into summary sheet

    Hi.. Can't post the code as the Sucurri firewall thingy stops it for whatever reason

    See attached workbook...
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-07-2017
    Location
    Australia
    MS-Off Ver
    office 2013
    Posts
    3

    Re: code to copy first rows and sheet titles from separate csv files into summary sheet

    Hi apo,

    The file works great, thank you very much! Just one more thing, is there any way how the file names
    of the original csv files (the ones from which the rows are imported)can be somehow written into
    one of the columns of each row as part of the import?
    The csv files contain results from simulations, but the file name contains a description of the
    case that has been simulated, so in the summary file it would be good to see both...

    thanks so much and regards

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

    Re: code to copy first rows and sheet titles from separate csv files into summary sheet

    Oops.. I missed that part.. see attached..
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-07-2017
    Location
    Australia
    MS-Off Ver
    office 2013
    Posts
    3

    Re: code to copy first rows and sheet titles from separate csv files into summary sheet

    Thank you so much! That sheet does exactly what I need now. Much appreciated, that really helps!

  7. #7
    Registered User
    Join Date
    10-08-2021
    Location
    London
    MS-Off Ver
    2013
    Posts
    1

    Re: code to copy first rows and sheet titles from separate csv files into summary sheet

    Hi Apo,

    Thank you for this!

    I also needed this function!

    All the best!

    Jags
    Last edited by jags320i; 10-08-2021 at 06:48 AM.

+ 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. copy cells and a range of rows to a summary sheet
    By mark-cox in forum Excel General
    Replies: 1
    Last Post: 10-09-2015, 12:20 PM
  2. Replies: 2
    Last Post: 04-11-2015, 07:56 AM
  3. Code to copy a row from multiple sheets to a summary sheet per criteria
    By rmwindham in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-29-2014, 11:05 AM
  4. Replies: 1
    Last Post: 03-28-2013, 02:49 PM
  5. [SOLVED] Summary sheet - copy cell contents from multiple sheets to one summary sheet
    By jsmity in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 10:32 AM
  6. Copy Rows to New Sheet (summary) when Criteria met.
    By brosario in forum Excel General
    Replies: 5
    Last Post: 03-05-2012, 10:15 AM
  7. Macro to copy rows from multiple worksheets to summary sheet
    By zmbd in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2011, 10:21 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