Results 1 to 9 of 9

Query connection referring to a cell value

Threaded View

  1. #1
    Registered User
    Join Date
    08-17-2010
    Location
    Oxford
    MS-Off Ver
    Excel 2010
    Posts
    27

    Query connection referring to a cell value

    Hello all,

    I am in my first forrays in working with excel queries and would like some advice. See attached spreadsheet for reference.

    I have recorded the queries code. This essentially inputs a range of data from a text file into excel. At the moment this is a specified text file (Metrics-GP22012BahrainR1Trummer.txt) which means that the same data is input every time the macro is run. So the current code looks like this:

      With ActiveSheet.QueryTables.Add(Connection:= _
            "TEXT;C:\Users\mdudley.ARDENINT\Documents\GP2\Metrics\Dev\Text Files\Metrics-GP22012BahrainR1Trummer.txt", _
            Destination:=Range("$J$10"))
            .Name = "Metrics-GP22012BahrainR1Trummer"
    I would like the file path to refer to a cell ($C$10) so as different .txt files are called up in the query depending on the selections made in the table ($C$3:$C$8). I suppose the code would be something like this:

      With ActiveSheet.QueryTables.Add(Connection:= _
            "TEXT;C:\Users\mdudley.ARDENINT\Documents\GP2\Metrics\Dev\Text Files\&"Range($C$10)"&.txt", _
            Destination:=Range("$J$10"))
            .Name = "Metrics-GP22012BahrainR1Trummer"
    This might not even be possible so simply but any advice anyone could give would be appreciated.

    Thanks,

    RanaldMetrics_Compare_03.xlsm
    Attached Images Attached Images

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