The MMULT function returns the matrix product of two arrays. The result is an array with the same number of rows as array1 and the same number of columns as array2.




Argument Description
array1, array2 The arrays you want to multiply

  The number of columns in array1 must be the same as the number of rows in array2
  Both arrays must contain only numbers
  array1 and array2 can be given as cell ranges, array constants, or references

Inputting Array Formulas: To input an array formula,

  1. highlight the range of cells for the function result, 
  2. type the function into the first cell of the range, and


  A B C D E F G H I
1   Product Quantity          
2 Customer Widgets Cogs Sprockets   Formula Result Notes
3 Buyer-1 14 9 3   {=MMULT(B3:D4,A7:B9)} $6,325 779 Column G is the sales to Buyer-1 and Buyer-2
4 Buyer-2 2 11 15     $9,525 2,195 Column H is the shipping weight of items sold to Buyer-1 and Buyer-2
6 Price Weight Product            
7 $200 4 Widgets            
8 $250 42 Cogs            
9 $425 115 Sprockets            

Note: The curly brackets, { and }, seen in the formulas in E2 and E7 are not entered by the user. Excel applies these to show the formula has been input as an array formula.

Common Function Error(s)

Problem What went wrong
#VALUE! Occurs if either:

  of the supplied arrays contains a blank or a non-numeric value
  the number of columns in array1 is not equal to the number of rows in array2
#N/A Occurs in cells outside the range of the resulting matrix, e.g. in the example above, had we highlighted cells G5-H5 while entering the MMULT function, those cells, not being part of the resulting matrix, will return the #N/A error

The matrix product of two matrices is given by multiplying the elements of each row of matrix 1 with the elements of each column of matrix 2, to create a resulting matrix that has the same number of rows as matrix 1 and the same number of columns as matrix 2.  For the following matrices:    

    \[     A = \left[ \begin{array}{ccc} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \end{array} \right]    \ \ \ \ \ \ B = \left[ \begin{array}{cc} b_{11} & b_{12}  \\ b_{21} & b_{22}  \\ b_{31} & b_{32} \end{array} \right]    \]

The matrix product array of the two arrays above, A & B is calculated as:

    \[    (AB)_{ij} = \sum_{k=1}^m A_{ik}B_{kj}    \]

where i is the row number, and j is the column number.

The following represents the matrix product calculation:

    \[     AxB = \left[ \begin{array}{ccccccc} a_{11}b_{11} + a_{12}b_{21} + a_{13}b_{31} \ \ \ & a_{11}b_{12} + a_{12}b_{22} + a_{13}b_{32}    \\ a_{21}b_{11} + a_{22}b_{21} + a_{23}b_{31} \ \ \ &a_{21}b_{12} + a_{22}b_{22} + a_{23}b_{32}  \end{array} \right]    \]

See Wikipedia for more information on matrix multiplication.