R
ryguy7272
Does anyone know of a relatively easy way to get 1, 3, 6, and 12 month
returns for a list of mutual fund symbols, from finance.yahoo.com?
For instance, if I have the following in A3:A7:
RPBAX
TRBCX
PRWCX
PRCOX
PRDMX
Range B2:E2 = 1-month, 3-months, 6-months, 12-months.
Now, for RPBAX, by right-clicking on the page and selecting ‘View Source’,
in the HTML, I see this:
<td class="yfnc_datamodlabel1">1-Month</td><td class="yfnc_datamoddata1"
align="right">4.05</td>
<td class="yfnc_datamodlabel1">3-Month</td><td class="yfnc_datamoddata1"
align="right">6.37</td>
<td class="yfnc_datamodlabel1">1-Year</td><td class="yfnc_datamoddata1"
align="right">31.03</td>
I guess I can loop through the list of funds, something like this:
Sub Import()
Dim str1 As String
Dim c As Range
For Each c In Sheets("Sheet1").Range("A3:A7")
str1 = "URL;http://finance.yahoo.com/q/pm?s=" & _
c.Value
With ActiveSheet.QueryTables.Add(Connection:=str1 _
, Destination:=Range("B3"))
.Name = str1
.Name = "ks?s=c.Value"
.WebFormatting = xlWebFormattingNone
.WebTables = "24"
.Refresh BackgroundQuery:=False
End With
Next c
End Sub
This doesn’t work; nothing is imported, and even if it were, the Range("B3")
is where I need to start, but then I need to something like offset(0,1),
Import 3-months, offset(0,1), Import 6-months, and offset(0,1), Import
12-months. Then something like offset(1,-4) to get to cell A4, and find the
returns for that fund. None of this logic is coded into the macro yet.
That’s probably not too hard to do, but I’m not exactly sure how to
incorporate it into the URL. Also, I don’t see the 6-month return anywhere
on the page. So, I’m thinking Yahoo doesn’t cover this metric, right. I
actually used to work for Yahoo, on the corporate finance side not on the
investment side. I suspect all these metrics come straight form the stock
exchanges, right.
I could forgo the 6-month metric if it doesn’t exist, but would like to pick
it up if there is a way. In any event, how would I code the macro above to
do what I described?
Thanks,
Ryan--
returns for a list of mutual fund symbols, from finance.yahoo.com?
For instance, if I have the following in A3:A7:
RPBAX
TRBCX
PRWCX
PRCOX
PRDMX
Range B2:E2 = 1-month, 3-months, 6-months, 12-months.
Now, for RPBAX, by right-clicking on the page and selecting ‘View Source’,
in the HTML, I see this:
<td class="yfnc_datamodlabel1">1-Month</td><td class="yfnc_datamoddata1"
align="right">4.05</td>
<td class="yfnc_datamodlabel1">3-Month</td><td class="yfnc_datamoddata1"
align="right">6.37</td>
<td class="yfnc_datamodlabel1">1-Year</td><td class="yfnc_datamoddata1"
align="right">31.03</td>
I guess I can loop through the list of funds, something like this:
Sub Import()
Dim str1 As String
Dim c As Range
For Each c In Sheets("Sheet1").Range("A3:A7")
str1 = "URL;http://finance.yahoo.com/q/pm?s=" & _
c.Value
With ActiveSheet.QueryTables.Add(Connection:=str1 _
, Destination:=Range("B3"))
.Name = str1
.Name = "ks?s=c.Value"
.WebFormatting = xlWebFormattingNone
.WebTables = "24"
.Refresh BackgroundQuery:=False
End With
Next c
End Sub
This doesn’t work; nothing is imported, and even if it were, the Range("B3")
is where I need to start, but then I need to something like offset(0,1),
Import 3-months, offset(0,1), Import 6-months, and offset(0,1), Import
12-months. Then something like offset(1,-4) to get to cell A4, and find the
returns for that fund. None of this logic is coded into the macro yet.
That’s probably not too hard to do, but I’m not exactly sure how to
incorporate it into the URL. Also, I don’t see the 6-month return anywhere
on the page. So, I’m thinking Yahoo doesn’t cover this metric, right. I
actually used to work for Yahoo, on the corporate finance side not on the
investment side. I suspect all these metrics come straight form the stock
exchanges, right.
I could forgo the 6-month metric if it doesn’t exist, but would like to pick
it up if there is a way. In any event, how would I code the macro above to
do what I described?
Thanks,
Ryan--