1081 Information from the Web
“URL;” & “http://ichart.fi nance.yahoo.com/table.csv?” & _
GetTTS() & _
GetDates() & _
“g=d&” & _
“ignore=.csv”
‘Create a new worksheet for the data; store
‘reference in ws
Set Ws = Worksheets.Add
‘Add our query to the worksheet; results should
‘go to column A
‘down from A2; store reference in wq
Set Wq = Ws.QueryTables.Add(Connection:=Url, _
Destination:=Ws.Range(“A1”))
‘Run our query in the foreground, i.e., wait
‘for the query to fi nish
Wq.Refresh BackgroundQuery:=False
‘Parse the text to columns; this is the approved
‘Microsoft way
Wq.ResultRange.TextToColumns _
Destination:=Wq.ResultRange.Range(“A1”), _
DataType:=xlDelimited, _
TextQualifi er:=xlDoubleQuote, _
Comma:=True
‘Number of rows minus 1 = number of returns
Nrows = Wq.ResultRange.Rows.Count - 1
‘insert returns formula in cloumn H down from H3
Ws.Range(“H3”, _
Ws.Cells(Nrows, 8)).FormulaR1C1 =
“=LN(R[-1]C[-1]/RC[-1])”
‘Returns are in column H down from cell H3
‘and for Nrows; so copy it
Ws.Range(Ws.Cells(3, 8), Ws.Cells(Nrows, 8)).Copy
Cws.Select ‘this is the worksheet we started from
‘Paste the values to the worksheet we started
‘from