+ Reply to Thread
Results 1 to 4 of 4

Import multiple CSV files into multiple sheets in a single workbook

  1. #1
    Registered User
    Join Date
    12-08-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Import multiple CSV files into multiple sheets in a single workbook

    Hi there.

    I have a requirement to import multiple CSV files with the exact same format into a single workbook, with each CSV equating to a new sheet that is then renamed to match the CSV filename.

    I did extensive research and found this thread that appears to do what I want but for some reason it is simply won't work for me
    http://www.excelforum.com/excel-gene...ml#post2367007

    Please Login or Register  to view this content.
    Before I get the obvious answers I have tried the following:
    - Edited the file path to where my files are stored
    - Turned off screen updating so that I can see what is going on
    - Tried stepping through the code using F8 and no errors were identified, but it it did not loop so clearly didn't see the files

    When I run the script I am getting no screen activity at all with nothing imported and no sign of life.

    Only thing I can think of is the version of excel.....I'm using Office 365 (whatever version that means now).

    Many thanks

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Import multiple CSV files into multiple sheets in a single workbook

    I would read this so you can learn how to walk through code.
    http://www.cpearson.com/excel/DebuggingVBA.aspx
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    12-08-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Import multiple CSV files into multiple sheets in a single workbook

    mikeTron - Thanks for the response.

    I've actually solved the problem now. For anyone else wanting to use the code in the future, you need to ensure that there is a trailing backslash "\" at the end of the file path that you are searching. Stupidly the answer was right in front of me with the comments even saying to do this.....DOH

    fPath = "D:\Dropbox\_Opportunities\PriceFinder Results\" 'path to CSV files, include the final \

    Code works Perfect folks.

  4. #4
    Registered User
    Join Date
    12-08-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Import multiple CSV files into multiple sheets in a single workbook

    Now that I have the script working I have noticed that if I import the files a second time and the worksheet already exists that it creates a second worksheet with a (2) appended to it instead of writing over the top of the existing data.

    Any assistance in how to overwrite the existing worksheet would be greatly appreciated.

+ 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] VBA to import multiple HTML files into a single tab
    By albanhac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2015, 04:26 PM
  2. Import Multiple Text Files into Single Workbook with Different Sheets
    By oliver.marshall001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2014, 09:29 AM
  3. Replies: 0
    Last Post: 11-28-2013, 12:03 PM
  4. [SOLVED] Import multiple csv files into current workbook as separate sheets
    By santosh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-31-2013, 04:19 AM
  5. Import Multiple Text Files Into Single Worksheet
    By cozandeffect in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-03-2011, 12:23 AM
  6. Multiple sheets in single workbook into new files only using cell format/values
    By MacApple in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2008, 04:00 PM
  7. Replies: 2
    Last Post: 08-30-2007, 12:34 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