Results 1 to 3 of 3

Thread: [Help] CSV auto import by Excel VBA

  1. #1

    Thread Starter
    Registered User
    Join Date
    May 2013
    Posts
    2

    Unhappy [Help] CSV auto import by Excel VBA

    Hi all,

    I have multiple excels file, multiple folders and multiple CSV files.

    e.g.
    Folder name: 2013-05-01
    Content:
    - test1.csv
    - test2.csv
    - test3.csv

    Folder name: 2013-05-02
    Content:
    - test1.csv
    - test2.csv
    - test3.csv

    Folder name: 2013-05-03
    Content:
    - test1.csv
    - test2.csv
    - test3.csv

    Folder name: 2013-05-04
    Content:
    - test1.csv
    - test2.csv
    - test3.csv

    Folder name: Test_Result
    Content:
    - test1.xls
    - test2.xls
    - test3.xls

    How do I using VBA to import the above CSVs into the Test_Result folder xls file(by the same name as the CSV and append after last sheet of original xls)
    and named the sheet by the folder Date?

    I would do the VBA automatically, as I open test1.xls then Run VBA. It asks selected the folders(i.e. 2013-05-01,2013-05-02, 2013-05-03 & 2013-05-04).
    Auto import all CSV which same name as "test1.csv" into the test1.xls.

    Thanks

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [Help] CSV auto import by Excel VBA

    you want all test1 in same sheet or each test1 in separate sheet?
    how to name sheets if the latter as they would all be named test1?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Registered User
    Join Date
    May 2013
    Posts
    2

    Re: [Help] CSV auto import by Excel VBA

    Hi,

    Thanks your reply.

    It's a test report.

    Each sheet name should be a date of the folder.

    By using another excel,
    1 select the test_result folder,
    2 select the test_result XLS that need to import
    3 select the date folder contain the csv files
    4 auto import all the "same test name" csv into "same test name" excel.

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width