DLW2
asked on
VBA Code to download historical stock quotes
I am using the following VBA code to download yahoo historical stock quotes. The result puts the stock quote csv into a single cell (destination C6). How would I modify the parameters so that each value in the table is put into a seperate cell? Thanks in advance to anyone that can help.
qurl = "http://ichart.yahoo.com/table.csv?s=" & Symb
qurl = qurl & "&a=9&b=6&c=2007&d=" & Month & "&e=" & _
Day & "&f=" & Year & "&g=d&ignore=.csv"
With ActiveSheet.QueryTables.Ad d(Connecti on:="URL;" & qurl, Destination:=Range("C6"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
qurl = "http://ichart.yahoo.com/table.csv?s=" & Symb
qurl = qurl & "&a=9&b=6&c=2007&d=" & Month & "&e=" & _
Day & "&f=" & Year & "&g=d&ignore=.csv"
With ActiveSheet.QueryTables.Ad
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Harr22:
Thank you - this worked. I was not aware of the text to column feature.
Thank you - this worked. I was not aware of the text to column feature.
OK thanks. I thought it was as simple as a missing parameter in the query tables statement but maybe not. I will give your suggestion a try. Dave
I don't think you can make the query return it in multiple columns. I fought with it for a while a couple years ago. Glad you got the text to columns method to work out for you, its a pretty cool feature.
ASKER
OK thanks. I thought it was as simple as a missing parameter in the query tables statement but maybe not. I will give your suggestion a try. Dave