View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default Import 1, 3, 6, and 12 month returns for a list of mutual fund

Finally had a chance to revisit this; that macro is pretty sweet! Thanks so
much Ron!! SO, there's no way to get the 6-month returns because it's not on
the site, right. I looked, but didn't see it anywhere. I looked on
www.google.com/finance and didn't see any 6-month return metrics there
either. It seems like it's not a popular thing, I guess. Does anyone know?

Thanks again Ron!
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"ron" wrote:

Ryan...Give the following code a try. I didn't see 6-month returns,
but it should grab the rest of what you want...Ron


Dim fund_array(5) As String

Sub Fund_Returns()
fundarray = Array("RPBAX", "TRBCX", "PRWCX", "PRCOX", "PRDMX")

For i = 0 To 4
' get the source code
my_url = "http://finance.yahoo.com/q/pm?s=" & fundarray(i)
Set my_obj = CreateObject("MSXML2.XMLHTTP")
my_obj.Open "GET", my_url, False
my_obj.send
my_var = my_obj.responsetext
Set my_obj = Nothing

' determine the yields
pos_1 = InStr(1, my_var, "1-Month", vbTextCompare)
pos_2 = InStr(pos_1, my_var, "right", vbTextCompare)
pos_3 = InStr(pos_2, my_var, "", vbTextCompare)
pos_4 = InStr(pos_3, my_var, "<", vbTextCompare)
one_month_yld = Mid(my_var, 1 + pos_3, pos_4 - (1 + pos_3))

pos_1 = InStr(1, my_var, "3-Month", vbTextCompare)
pos_2 = InStr(pos_1, my_var, "right", vbTextCompare)
pos_3 = InStr(pos_2, my_var, "", vbTextCompare)
pos_4 = InStr(pos_3, my_var, "<", vbTextCompare)
three_month_yld = Mid(my_var, 1 + pos_3, pos_4 - (1 + pos_3))

pos_1 = InStr(1, my_var, "1-Year", vbTextCompare)
pos_11 = InStr(1 + pos_1, my_var, "1-Year", vbTextCompare)
pos_2 = InStr(pos_11, my_var, "right", vbTextCompare)
pos_3 = InStr(pos_2, my_var, "", vbTextCompare)
pos_4 = InStr(pos_3, my_var, "<", vbTextCompare)
one_year_yld = Mid(my_var, 1 + pos_3, pos_4 - (1 + pos_3))

' put the data where you want
Range("A" & 1 + i) = fundarray(i)
Range("B" & 1 + i) = one_month_yld
Range("C" & 1 + i) = three_month_yld
Range("D" & 1 + i) = one_year_yld
Next
End Sub


.