+ Reply to Thread
Results 1 to 3 of 3

Import CSV file using variables

  1. #1
    Registered User
    Join Date
    07-19-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    8

    Import CSV file using variables

    Okay, so I'm new to the forum, so here's a quick back ground. I've got medium exp in basic programming, and fairly good with excel, but only been programming macros for a month or so. Anyway, here's what I'm after. I've got a list of filter names in column "A", such as

    WGC
    WGD
    WGE

    each of those names correspond to a folder in the path bellow.

    In a perfect world, I would select one of those cells, and hit a command button that runs a pretty gnarly macro. Part of that macro imports a CSV file to a different sheet. As it is right now, I have to manually select the files, and the closest thing I've been able to manage as a short cut is to have the starting location be the "filters" folder.

    Here's the only part I'm having trouble with, sense the files and folders are all 100% predictable, I'd like it if the file were automatically selected. Here's what I've tried so far.

    Please Login or Register  to view this content.
    Obviously, the bold section is where the problem is. Am I on a fools errand here??
    Last edited by Cutter; 07-25-2012 at 10:22 PM. Reason: Added code tags

  2. #2
    Registered User
    Join Date
    07-19-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Import CSV file using variables

    Is the problem with my explanation of the problem, or is this just not possible??

  3. #3
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Import CSV file using variables

    It's not clear to me exactly what you want. Also, why are you importing the .csv file with QueryTables.Add?

    Do you want to import each .csv file into a new worksheet in the active workbook? If so, see if you can adapt the code in this thread - http://www.excelforum.com/excel-prog...-in-cells.html. You would need to amend the Workbooks.Open line to specify the file path and file name of each .csv file, and the line which names the newly inserted sheet - the Sheets(...).Name line.
    Post responsibly. Search for excelforum.com

+ 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