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
Bookmarks