Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import csv files (Excel XP)

    Edited by HansV to provide link to post - see <!help=19>Help 19<!/help>.

    Found at <post#=596072>post 596072</post#> a method to import numerous csv files into an Excel workbook. It works fine. Playing around with it I changed the csv portion in "strfile = Dir(strPath & "*.csv") to .xls. I could then import a number of xls files into a new workbook. However one thing I noted is that instead of carrying the correct name over in the name tag, many of the tags read Sheet2 (1), Sheet3(1), Sheet3(2), etc. All Name tags did have proper names and were not the default names which Excel gives.

    Any suggestion as to why it is not capturing the correct sheet names?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import csv files (Excel XP)

    I can't reproduce the error. When I try the code (with *.csv changed to *.xls), the original sheet names are copied. Excel only adds a sequence number if there are duplicate sheet names.

  3. #3
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import csv files (Excel XP)

    Thanks for the quick reply. I'll take a closer look at the workbooks in question to make sure that I have the Name tags appropriately named.

  4. #4
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import csv files (Excel XP)

    Hans, is there a quick way to change this code so that all csv files will load onto one sheet in Excel? This would save having to cut and paste the information from each worksheet to a master worksheet.

    Thanks.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import csv files (Excel XP)

    How would you want to arrange the data from the different files? Below each other? With a blank row in between, or not?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import csv files (Excel XP)

    Would you want the column headers to be copied or not?

  7. #7
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import csv files (Excel XP)

    <P ID="edit" class=small>(Edited by kiazd on 27-Sep-06 21:53. )</P>Sorry, I should have mentioned that each csv contains the identical information with same column headings. As information is copied it would fill in the rows below. Hopefully this is clear.

    No blank rows between

  8. #8
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import csv files (Excel XP)

    No. Thank you.

    Stupid me, of course I want the first one

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import csv files (Excel XP)

    Originally, you asked about .xls files, now it appears to be about .csv files again. Which is it, exactly?

  10. #10
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import csv files (Excel XP)

    Files at work are csv being imported to Excel.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Import csv files (Excel XP)

    I have attached some code based on that by Jezza from the post you referred to. It'll copy the contents of all CSV files in a folder to a single worksheet, copying the header row only once.

  12. #12
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import csv files (Excel XP)

    Hans, thank you very much. Got back to the office this morning and ran the code. Saved me much time by not having to cut and paste from 75 sheets over to one master.

Posting Permissions

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