tags:

views:

20

answers:

1

This line of VBA code downloads a CSV file from the web and dumps the data into a spreadsheet. Can someone please help me figure out how to tweak the SQL in this code in order to select the "Close" column in the CSV table and insert that column into the spreadsheet? Thank you!

Sub test()
Dim sqldata As QueryTable

 Set sqldata = ActiveSheet.QueryTables.Add( _
 Connection:="TEXT;http://ichart.finance.yahoo.com/table.csv?s=JAZZ&d=9&e=3&f=2010&g=d&a=5&b=1&c=2007&ignore=.csv" & _
 "sqlstring= SELECT * from table", _
 Destination:=Range("A1"))

 With sqldata
 .TextFileCommaDelimiter = True
 .Refresh 'executes the retreival
 End With
 End Sub
A: 

Here is an alternative to reach your final result. May be it is not the right way to do this but i have tested it and it works.

After you get the data you can execute this:

Application.ScreenUpdating = False
Range("A:A,B:B,C:C,D:D,F:F,G:G").Select
Range("G1").Activate
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Application.ScreenUpdating = True
Jorge