View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Programming help

No need to create a csv workbook for each symbol. You could use
querytables.add instead to import to a data worksheet and then copy/paste to
a sheet that shows all symbols, side by side. Here is part of my macro that
does this.
You can also use a double click event to graph the results.
Date ^TYX ^TnX ^FvX ^IRX ^OTX ^dji
6/20/2003 4.46 3.40 2.30 0.81
151.08 9,200.75
6/19/2003 4.42 3.34 2.24 0.79
151.72 9,179.53
6/18/2003 4.39 3.36 2.30 0.86
153.98 9,293.80
6/17/2003 4.30 3.27 2.22 0.87
151.33 9,323.02
6/16/2003 4.22 3.17 2.11 0.84
151.26 9,318.96


For Each c In [SL]
On Error Resume Next
strurl = "http://table.finance.yahoo.com/table.csv?a=" & StartMo & "&b=" &
StartDay & "&c=" & StartYr & "&d=" & StopMo & "&e=" & StopDay & "&f=" &
StopYr & "&y=0&g=" & [e2] & "&s=" & c & ""

With ActiveWorkbook.Worksheets("Data").QueryTables.Add( _
Connection:="URL;" & strurl, Destination:=Worksheets("Data").Cells(1,
1))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
copy/paste code here
Next


--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
Sub Tester3()
Dim cell As Range
Dim wkbk As Workbook
For Each cell In Range("A1:A500")
sName = "C:\Data\" & cell.Value & ".csv"
Set wkbk = _
Workbooks.Open( _
"http://chart.yahoo.com/table.csv?a=9&b=1&" & _
"c=2002&d=5&e=30&f=2004&s=" & _
cell.Value & _
"&y=0&g=d&ignore=.csv")
On Error Resume Next
' delete existing file with this name
Kill sName
On Error GoTo 0
wkbk.SaveAs FileName:=sName, _
FileFormat:=xlCSV
wkbk.Close SaveChanges:=False
Next
End Sub

--
Regards,
Tom Ogilvy

Me wrote in message
...
I'm fairly new to Excel and VBA.

Here is the situation:

1. I have a spreadsheet containing the symbols for the S&P500 index in
A2:A501.

2. I can download data for a single symbol using the yahoo website:

http://chart.yahoo.com/d?a=9&b=1&c=2...&f=2004&g=d&s=

which will give me a link at the bottom of the page to download 200
days of data in .CSV format.

3. I need to collect the data for all of the 500 symbols and save them
to a /DATA driectory as *.csv

4. I need to be able to do daily updates

5. I need to be able to automate this whole process

Any help appreciated