title: Type mismatch error in VBA when using mmult loops
body: <p>I am creating a code to calculate the portfolio standard deviation of equal-weighted portfolio of stocks from 1 to 40 stocks. The matrix formula for portfolio variance is just w^T<em>sigma</em>w where w = column vector weights of each stock, sigma = the variance covariance matrix and w^T is the transpose of the column vector</p>
  
  <p>I have created the variance covariance matrix, a row vector of weights, and I am running a loop to calculate the portfolio variance. The code for the loop is below, but I am getting the error that "Unable to get the MMult property of the WorksheetFunction class"</p>
  
  <p>Could someone please shed some light?</p>
  
  <pre><code>Sub StandardDeviation()
  
      Dim i As Integer, j As Integer
  
  
      Worksheets("Trial 1").Activate
      Range("B80").Select
  
      For i = 1 To 40
  
  
  
      Cells(80, i + 1) = Application.WorksheetFunction.MMult(Application.WorksheetFunction.MMult(Range(Cells(124 + i, 2).Address &amp; ":" &amp; Cells(124 + i, 1 + i).Address), Range(Cells(83, 2).Address &amp; ":" &amp; Cells(83 + i, 1 + i).Address)), Application.WorksheetFunction.Transpose(Range(Cells(124 + i, 2).Address &amp; ":" &amp; Cells(124 + i, 1 + i).Address)))
  
  
  
      Next
  
  
  
  End Sub
  </code></pre>