MMULT returns the matrix product of two arrays. It multiplies rows of the first array by columns of the second to produce a new array of results.
=MMULT(array1, array2)What does MMULT do?
The MMULT function performs matrix multiplication in Excel. It takes two arrays (ranges of numbers) and returns a new array where each element is the sum of the products of a row from the first array and a column from the second array. This is useful for combining data in ways that simple multiplication cannot.
Matrix multiplication is a powerful technique for calculating totals across multiple categories, applying weights to scores, or transforming data. Instead of writing long formulas with SUMPRODUCT or manual multiplication, MMULT lets you do it in one step. It is especially handy when you need to multiply a row of quantities by a column of prices, or when you want to compute weighted sums for many items at once.
For example, imagine you have a table of monthly sales for several products and a separate table of unit prices. You can use MMULT to calculate the total revenue for each product across all months in a single formula. This saves time and reduces errors compared to multiplying and adding each pair manually.
When to use MMULT
- Calculating total revenue by multiplying quantities sold by unit prices.
- Computing weighted averages or scores where each item has a different weight.
- Combining multiple criteria totals, such as summing sales across regions and products.
- Transforming data in linear algebra or statistics, like multiplying a matrix by a vector.
- Creating dynamic summaries that update automatically when source data changes.
MMULT syntax
=MMULT(array1, array2)| Argument | Required? | What to enter |
|---|---|---|
array1 | Required | The first array or range of numbers to multiply. The number of columns in array1 must equal the number of rows in array2. For example, a 2x3 range (2 rows, 3 columns). |
array2 | Required | The second array or range of numbers. The number of rows must match the number of columns in array1. For example, a 3x2 range (3 rows, 2 columns). |
What it returns: MMULT returns an array (a matrix) of numbers. The result has the same number of rows as array1 and the same number of columns as array2. In Excel 365, the result spills into neighbouring cells. In older versions, you may need to enter it as an array formula (Ctrl+Shift+Enter).
MMULT examples
1 Multiply a 2x2 matrix by a 2x2 matrix
Here we multiply two 2x2 matrices to produce another 2x2 matrix. The formula =MMULT(A2:B3, D2:E3) multiplies the first matrix (A2:B3) by the second (D2:E3). The result is a 2x2 array where each element is the sum of products of a row from the first matrix and a column from the second. For example, the top-left element is 1*5 + 2*7 = 5 + 14 = 19. The result spills into cells G2:H3, but we show the top-left value in G2 as 19.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Matrix1 | Matrix2 | ||||||
| 2 | 1 | 2 | 5 | 6 | 19 | |||
| 3 | 3 | 4 | 7 | 8 | ||||
| 4 |
2 Calculate total sales for each product across months
This example shows a table of monthly sales for three products. We want the total sales for each product. The formula =MMULT(B2:D4, {1;1;1}) multiplies the 3x3 sales matrix by a column of ones (a 3x1 vector). This effectively sums each row. The result is a 3x1 array with the totals: 100+150+200=450 for Product A, 200+250+300=750 for Product B, and 300+350+400=1050 for Product C. The first total appears in F2 as 450.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Product | Jan | Feb | Mar | |||
| 2 | Product A | 100 | 150 | 200 | 450 | ||
| 3 | Product B | 200 | 250 | 300 | |||
| 4 | Product C | 300 | 350 | 400 | |||
| 5 |
3 Compute weighted average scores for students
We have scores for three students on three exams and weights for each exam. The formula =MMULT(B2:D4, F2:F4) multiplies the scores matrix (3x3) by the weights column (3x1). This gives a weighted sum for each student. For Alice: 80*0.2 + 90*0.3 + 70*0.5 = 16 + 27 + 35 = 78. The result is a 3x1 array of weighted sums. The first value appears in H2 as 78.
| A | B | C | D | E | F | G | H | I | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Student | Exam1 | Exam2 | Exam3 | Weights | ||||
| 2 | Alice | 80 | 90 | 70 | 0.2 | 78 | |||
| 3 | Bob | 70 | 80 | 90 | 0.3 | ||||
| 4 | Carol | 90 | 70 | 80 | 0.5 | ||||
| 5 |
4 Calculate revenue by region and product using two tables
This example combines a sales quantity table (regions x products) with a price table (products x regions) to compute revenue. The formula =MMULT(B2:D4, F2:G4) multiplies the 3x3 quantity matrix by the 3x2 price matrix. The result is a 3x2 matrix where each element is the revenue for a region-product combination. For North and Product A: 10*5 + 20*10 + 30*15 = 50 + 200 + 450 = 700. The top-left result appears in I2 as 700.
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Region | Product A | Product B | Product C | Price A | Price B | ||||
| 2 | North | 10 | 20 | 30 | 5 | 10 | 700 | |||
| 3 | South | 15 | 25 | 35 | 10 | 15 | ||||
| 4 | East | 5 | 10 | 15 | 15 | 20 | ||||
| 5 |
Common MMULT errors and how to fix them
| Error | Why it happens | How to fix it |
|---|---|---|
| #VALUE! | The number of columns in array1 does not equal the number of rows in array2, or one of the arrays contains non-numeric values. | Ensure that the first array has the same number of columns as the second array has rows. Also check that all cells in both ranges contain numbers (or are empty). |
| #N/A | In older Excel versions, the result array does not fit into the selected range, or the formula was not entered as an array formula. | Select the correct output range before entering the formula, and press Ctrl+Shift+Enter to enter it as an array formula. In Excel 365, the result spills automatically, so ensure there is enough empty space. |
| #VALUE! | One or both arguments are text instead of numbers. | Convert text to numbers or remove text from the ranges. Use VALUE function if necessary. |
| #REF! | The formula refers to cells that have been deleted or moved. | Check the cell references and adjust them to valid ranges. |
Tips for using MMULT
- Use MMULT to replace long SUMPRODUCT formulas when you need to multiply rows by columns and sum the results.
- In Excel 365, MMULT spills results automatically; make sure there is enough empty space to the right and below the target cell.
- You can use array constants like {1;1;1} inside MMULT to sum rows or columns quickly.
- Remember that matrix multiplication is not commutative: MMULT(A,B) is not the same as MMULT(B,A).
- Combine MMULT with TRANSPOSE to multiply a column by a row and get a matrix of all pairwise products.
- Use the F9 key to evaluate parts of the formula and see intermediate arrays.
Frequently asked questions
What is the difference between MMULT and SUMPRODUCT?
SUMPRODUCT multiplies corresponding elements of two arrays and returns a single sum. MMULT performs matrix multiplication and returns an array of results. Use MMULT when you need multiple outputs, such as totals for several rows at once.
Can MMULT handle more than two arrays?
No, MMULT only accepts two arrays. To multiply three matrices, nest MMULT: =MMULT(MMULT(array1, array2), array3).
Why do I get a #VALUE! error with MMULT?
The most common cause is mismatched dimensions: the number of columns in the first array must equal the number of rows in the second array. Also ensure all cells contain numbers.
Does MMULT work with non-numeric data?
No, MMULT requires numeric values. Text or empty cells may cause errors or be treated as zero, depending on the context. It's best to use only numbers.
How do I enter MMULT in older Excel versions?
In Excel 2019 and earlier, you must select the output range, type the formula, and press Ctrl+Shift+Enter to enter it as an array formula. In Excel 365, it spills automatically.
Related functions
Every example on this page was recalculated by SheetSkill’s spreadsheet engine. MMULT reference