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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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