A macro for portfolio variance

pallavmishra

New Member
Joined
Jul 2, 2009
Messages
1
Hi,

I am trying to automate a variance-covariance matrix to calculate portfolio variance for each day for 510 days. My macro, however, is overwriting the output for each cell. Please help me with the problem. Is there a way I could attach the Excel sheet?

Sub PortVar()
Dim i As Integer
For i = 1 To 510
Range("AA6").Value = Cells(3 + i, 10).Value
Range("AB7").Value = Cells(3 + i, 11).Value
Range("AC8").Value = Cells(3 + i, 12).Value
Range("AD9").Value = Cells(3 + i, 13).Value
Range("AB6").Value = Cells(3 + i, 14).Value
Range("AA7").Value = Range("AB6").Value
Range("AC6").Value = Cells(3 + i, 15).Value
Range("AA8").Value = Range("AC6").Value
Range("AD6").Value = Cells(3 + i, 16).Value
Range("AA9").Value = Range("AD6").Value
Range("AC7").Value = Cells(3 + i, 17).Value
Range("AB8").Value = Range("AC7").Value
Range("AD7").Value = Cells(3 + i, 18).Value
Range("AB9").Value = Range("AD7").Value
Range("AD8").Value = Cells(3 + i, 19).Value
Range("AC9").Value = Range("AD8").Value
Cells(3 + i, 21).Select
Selection.FormulaArray = "=MMULT(MMULT(R5C27:R5C30,R6C27:R9C30),R6C26:R9C26)"
Next i
End Sub



Thanks

Pallav

Excel version: 2013 Pro. Macro name: PortVar
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,215,992
Messages
6,128,170
Members
449,429
Latest member
ianharper68

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top