I am using VBA in excel to extract information from an investment program's database using codes provided with the program.
I have listed 39 fund symbols (kind of like stock symbols) in the range a2:a40. Now, I am trying to display return values for each fund beside the fund's name in column B.
The fund name in A2 is $MGRO. So, when I use the code:
the annreturn value appears in cells B2:B40.Dim annreturn As Variant
Dim startdate As Variant
Dim enddate As Variant
Range("b2").Select
Do Until ActiveCell.Offset(0, -1).Value = ""
ActiveCell.Value = ft.annreturn((ft.divadjprices("$MGRO")), #2/16/2000#, #2/16/2010#)
ActiveCell.Offset(1, 0).Select
Loop
How do I replace "$MGRO" with a value that will replace $MGRO with the symbol relevant to each row?
I have tried using the codes:
andDim annreturn As Variant
Dim startdate As Variant
Dim enddate As Variant
varSym = ActiveCell.Offset(0, -1).Value
Range("b2").Select
Do Until ActiveCell.Offset(0, -1).Value = ""
ActiveCell.Value = ft.annreturn((ft.divadjprices("varsym")), #2/16/2000#, #2/16/2010#)
ActiveCell.Offset(1, 0).Select
Loop
End Sub
But both codes return "-999900" in the destination cells. (This is the same thing that gets returned if you plug invalid symbols into the function.)Dim annreturn As Variant
Dim startdate As Variant
Dim enddate As Variant
varSym = Range("a2").Value
Range("b2").Select
Do Until ActiveCell.Offset(0, -1).Value = ""
ActiveCell.Value = ft.annreturn((ft.divadjprices("varsym")), #2/16/2000#, #2/16/2010#)
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Can anyone help me figure out how to make this work?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks