Link to home
Create AccountLog in
Avatar of DLW2
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.Add(Connection:="URL;" & qurl, Destination:=Range("C6"))
                .BackgroundQuery = True
                .TablesOnlyFromHTML = False
                .Refresh BackgroundQuery:=False
                .SaveData = True
             End With
ASKER CERTIFIED SOLUTION
Avatar of harr22
harr22
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of DLW2
DLW2

ASKER

Harr22:

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
Avatar of DLW2

ASKER

Harr22:

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.