Here is an Excel VBA code for downloading open, high, low, close, volume data.
Insert Data label in Sheet1.
A1 - Yahoo Finance Stock Code
B1 - Open
C1 - High
D1 - Low
E1 - Close
D1 - Volume
E.g.
A2 - U11.SI
A3 - D05.SI
etc
This is the Excel VBA code for downloading o,h,l,c,v data.
Sub Get_Yahoo_Finance_data()
Dim i As Integer, j As Integer
Dim dl_url As String
Dim dl_url_stock As String
Dim dl_string As String
Dim stock_data As Variant
Dim WinHttpReq As Object
'Get the Yahoo Finance code from thie website
http://www.financialwisdomforum.org/gummy-stuff/Yahoo-data.htm
dl_url = "http://finance.yahoo.com/d/quotes.csv?s=xxxx&f=ohgl1v"
Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
For i = 1 To ThisWorkbook.Sheets("Sheet1").UsedRange.Rows.Count - 1
dl_url_stock = Replace(dl_url, "xxxx", ThisWorkbook.Sheets("Sheet1").Range("A1").Offset(i, 0))
WinHttpReq.Open "GET", dl_url_stock, False
WinHttpReq.Send
dl_string = WinHttpReq.responseText
If Len(dl_string) > 0 Then
stock_data = Split(dl_string, ",")
For j = 0 To 4
ThisWorkbook.Sheets("Sheet1").Range("A1").Offset(i, j + 1) = Replace(stock_data(j), Chr(10), "")
Next j
End If
Next i
End Sub