Hi All,
Below is a macro I use to get real time price quotes from Google Finance. Each time I change the stock ticker in cell B3 and run the macro the query table appends the new ticker to the returned data. For instance, the first time I ran the macro with ticker AAPL, it put AAPL in E44 and the price of AAPL in F44. When I changed the ticker in B3 to GOOG, I expected it to replace the old data and put GOOG in E44 and the price of GOOG into F44. Instead, it still had AAPL in E44 and the price of AAPL in F44, and it put GOOG in E45 and the price of GOOG of F45. Changing B3 to a third ticker resulted in this new ticker and price showing in E46 and F46.
Why is this happening and where is the growing list of tickers stored?
Thanks,
Eric
Below is a macro I use to get real time price quotes from Google Finance. Each time I change the stock ticker in cell B3 and run the macro the query table appends the new ticker to the returned data. For instance, the first time I ran the macro with ticker AAPL, it put AAPL in E44 and the price of AAPL in F44. When I changed the ticker in B3 to GOOG, I expected it to replace the old data and put GOOG in E44 and the price of GOOG into F44. Instead, it still had AAPL in E44 and the price of AAPL in F44, and it put GOOG in E45 and the price of GOOG of F45. Changing B3 to a third ticker resulted in this new ticker and price showing in E46 and F46.
Why is this happening and where is the growing list of tickers stored?
Code:
Option Explicit
Sub GetData()
Dim DataSheet As Worksheet
Dim Symbol As String
Dim qurl As String
Application.ScreenUpdating = False
Range("Data").Cells.Clear 'uses named range "Data"
Set DataSheet = ActiveSheet
Symbol = DataSheet.Range("B3").Value
qurl = "http://finance.google.com/finance?q=" & Symbol
With Sheets("Data").QueryTables.Add(Connection:="URL;" & qurl, Destination:=Sheets("Data").Range("E1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.Refresh BackgroundQuery:=False
.SaveData = True
End With
Application.ScreenUpdating = True
End Sub
Thanks,
Eric