+ Reply to Thread
Results 1 to 6 of 6

Import CSV files to new tabs

  1. #1
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Import CSV files to new tabs

    The situation I am in is that I have a couple of .csv files with different names that follow the trend like kieranqueryone, kieranquerytwo and so on.

    What I want to do is from a dashboard I have, at a click of a button it opens the fileopen dialog and let's me import these csv files to excel but for each file I open it puts it to a new tab with the csv file's name if that's possible at all?

    I've searched the forum but cannot find anything like it, if someone could get me started or direct me to something I might have missed I would duely appreicate it.
    where I am up to:
    Please Login or Register  to view this content.
    no idea if what I have so far will work, I've editted it slightly from when I imported excel sheets. but I need to say if wsSheet.Name = "KieranQueryOne" or "KieranQueryTwo" etc or a way around that so I can just import any file name then say put each csv files information to a new tab
    Last edited by kieranbop; 03-14-2012 at 04:11 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Import CSV files to new tabs

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Import CSV files to new tabs

    Morning snb, Just tried running your code sample, so I get the open dialog, choose a csv file click open, then nothing happens am I missing something or?

    Uploaded a sample of the form, runs on the click of "test" in main menu and is in the "test" module.
    Do I not need an a variant or something to hold the location of the file when it does it?
    Attached Files Attached Files
    Last edited by kieranbop; 03-14-2012 at 05:23 AM. Reason: more info

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Import CSV files to new tabs

    test this:
    Please Login or Register  to view this content.
    after that:

    Please Login or Register  to view this content.
    Last edited by snb; 03-14-2012 at 05:34 AM.

  5. #5
    Forum Contributor
    Join Date
    09-08-2011
    Location
    Leicester, England
    MS-Off Ver
    Excel 2007
    Posts
    157

    Re: Import CSV files to new tabs

    They both come up with the same problem:
    Run time error '1004':
    Excel cannot insert the sheets into the destination workbook because it contains fewer rows and columns than the source workbook ..

    obviously I changed the file address on your first one

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Import CSV files to new tabs

    I only got that message in your file.
    Try it in a new workbook.
    I tested in Excel 2000 and Excel 2010

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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