J
jsuden
My macro shoudl work as follows: i have 2 sheets, AG and Summary. On
the AG sheet, I have 20 short list funds (starting in cell A76) that I
want to add in to the current portfolio at a 5% weighting (which is in
column D), and then I calculate the new volatility, return, beta to teh
S&P and correlation to the S&P. The Summary sheet links to the AG sheet
and to the specific cells that contain these new results, so for
example C4 on Summary links to the new volatility of the portfolio with
the short list fund, G4 links to the new return, O4 links to the new
beta and S4 links to the new correl. Now I want to take these numbers
(say C4) and copy paste special the value to D4. Then it shd go back,
make the % of the first short list fund equla to 0% and the second fund
should now be equal to 5%. THe links are still the same so now I want
to copy, pastespecial C4 to D5, and so on. The code below does not loop
through (stays on AG.D76, when it shd go to AG.D77 and so on). It also
goes to cell C3 in the summary worksheet instaed of C4 and doesnt seem
to be doing any pasting. Is this code completely wrong? ANy
suggestions?
Dim i As Integer
For i = 0 To 20
Do Until i = 20
Application.GoTo Sheets("AG").Range("A76") 'this needs to reflect where
list starts
ActiveCell.Offset(0 + i, 3).Select 'weighting starts in column D76,
then goes to D77, etc
ActiveCell.FormulaR1C1 = "5%" 'changes weight from 0 to 5%
Application.GoTo Sheets("Summary").Range("C4")
Selection.Copy 'copy volatility to adjacent cell
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Application.GoTo Sheets("Summary").Range("G4") 'copy return
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("Summary").Range("O4") 'copy beta
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("Summary").Range("S4") 'copy correlation
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("AG").Range("A76")
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "0%" 'change D76 back to 0%
Loop ' go to D77 and repeat actions up until D95
Next i
End Sub
the AG sheet, I have 20 short list funds (starting in cell A76) that I
want to add in to the current portfolio at a 5% weighting (which is in
column D), and then I calculate the new volatility, return, beta to teh
S&P and correlation to the S&P. The Summary sheet links to the AG sheet
and to the specific cells that contain these new results, so for
example C4 on Summary links to the new volatility of the portfolio with
the short list fund, G4 links to the new return, O4 links to the new
beta and S4 links to the new correl. Now I want to take these numbers
(say C4) and copy paste special the value to D4. Then it shd go back,
make the % of the first short list fund equla to 0% and the second fund
should now be equal to 5%. THe links are still the same so now I want
to copy, pastespecial C4 to D5, and so on. The code below does not loop
through (stays on AG.D76, when it shd go to AG.D77 and so on). It also
goes to cell C3 in the summary worksheet instaed of C4 and doesnt seem
to be doing any pasting. Is this code completely wrong? ANy
suggestions?
Dim i As Integer
For i = 0 To 20
Do Until i = 20
Application.GoTo Sheets("AG").Range("A76") 'this needs to reflect where
list starts
ActiveCell.Offset(0 + i, 3).Select 'weighting starts in column D76,
then goes to D77, etc
ActiveCell.FormulaR1C1 = "5%" 'changes weight from 0 to 5%
Application.GoTo Sheets("Summary").Range("C4")
Selection.Copy 'copy volatility to adjacent cell
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
Application.GoTo Sheets("Summary").Range("G4") 'copy return
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("Summary").Range("O4") 'copy beta
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("Summary").Range("S4") 'copy correlation
Selection.Copy
ActiveCell(0 + i, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues
Application.GoTo Sheets("AG").Range("A76")
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "0%" 'change D76 back to 0%
Loop ' go to D77 and repeat actions up until D95
Next i
End Sub