+ Reply to Thread
Results 1 to 8 of 8

Need to know how to merge all .csv files in one forder to a single excel file

  1. #1
    Registered User
    Join Date
    01-08-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    4

    Need to know how to merge all .csv files in one forder to a single excel file

    I am very new to excel macros.
    Could anyone help me to create a macro to merge all *.csv files in one folder to a single new excel file in other folder?

    Thanks a lot in advance...

  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: Need to know how to merge all .csv files in one forder to a single excel file

    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
    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
    01-08-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need to know how to merge all .csv files in one forder to a single excel file

    Thanks a lot for the code. But I got a "Compile error: Variable not defined" message, and stopped on "lrow = ..." line.
    Could you help me out again. - 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: Need to know how to merge all .csv files in one forder to a single excel file

    Oops. Just add dim lrow as long at the end of all the dim statements.

  5. #5
    Registered User
    Join Date
    01-08-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need to know how to merge all .csv files in one forder to a single excel file

    Thanks, no more compile error. however I didn't get a result that I was looking for. Maybe I didn't explain well on my expected result.
    I am trying to read all *.csv file in folder and put in one excel file as worksheet per .csv file.
    So, if I read 5 csv files, I would expect 5 sheets with each csv file name in the excel file.

    Would that be possible? Thanks a lot for you help

  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: Need to know how to merge all .csv files in one forder to a single excel file

    Updated code -
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-08-2013
    Location
    Chicago
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need to know how to merge all .csv files in one forder to a single excel file

    Works great! thanks a lot for your fast response

  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: Need to know how to merge all .csv files in one forder to a single excel file

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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