Like this:
Public Function GetClose(ticker As String, closeDate As Date) As Double
Dim results
Dim m0nth As String
If month(closeDate) < 10 Then m0nth = "0" & month(closeDate) - 1 Else m0nth = month(closeDate) - 1
With CreateObject("msxml2.xmlhttp")
.Open "Get", "http://finance.yahoo.com/q/hp?s=" & ticker & _
"&a=" & m0nth & _
"&b=" & Day(closeDate) & _
"&c=" & Year(closeDate) & _
"&d=" & m0nth & _
"&e=" & Day(closeDate) & _
"&f=" & Year(closeDate) & "&g=d"
.send
Do: DoEvents: Loop Until .readyState = 4
results = Split(.responseText, "<td class=""yfnc_tabledata1"" align=""right"">")
.abort
GetClose = Val(results(UBound(results)))
End With
End Function
Bookmarks