## How to use the MMULT function

The MMULT function calculates the matrix product of two arrays, an array as the same number of rows as array1 and columns as array2.

### Excel Function Syntax

MMULT(*array1*, *array2*)

### Arguments

array1 |
Required. The first array of numbers you want to multiply. |

array2 |
Required. The second array of numbers you want to multiply. |

### Comments

*"For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the second matrix. The resulting matrix has the number of rows of the first and the number of columns of the second matrix." Source: Wikipedia*

This function must be entered as an array formula.

**Update January 2020**

Microsoft Excel has recently released an update to Excel 365 subscribers which allows you to use a new feature called dynamic array that replaces a regular array formula.

The image above shows the MMULT function in cell B12, however, it has been entered as a regular formula. Excel "knows" that it returns multiple values and automatically expands the range.

This is called "spilled array behavior" meaning the formula expands across cells automatically in order to show all values.

There is a blue border around the values from a spilled array but it will disappear as soon as you click a cell outside the blue border. It reappears again if you click any cell in the spilled array.

The following examples demonstrate how the function works.

### Cell ranges with an equal number of rows and columns

Array1 (B2:C3) has **2** rows and array2 (E2:F3) has **2** columns, the returning array has **2** rows and **2** columns. Cell range B2:C3 and E2:F3 show the cell labels.

Cell range H2:I3 shows the calculations for each value in the array using the labels in B2:C3 and E2:F3.

Array formula in cell range L8:M9:

Cell L8: a11*b11+a12*b21 becomes 0*0+1*1 and returns 1.

Cell L9: a21*b11+a22*b21 becomes 1*0+0*1 and returns 0.

Cell M8: a11*b12+a12*b22 becomes 0*1+1*0 and returns 0.

Cell M9: a21*b12+a22*b22 becomes 1*1+0*0 and returns 1.

### Cell ranges with different number of rows and columns, example 1

Array1 (B2:C4) has **3** rows and array2 (E2:G3) has **3** columns, the returning array has **3** rows and **3** columns.

**Array formula in cell range L8:M9:**

Cell M8: a₁₁*b₁₁+a₁₂*b₂₁ becomes 0*1+1*4 and returns 4

Cell M9: a₂₁*b₁₁+a₂₂*b₂₁ becomes -4*1+0*4 and returns -4

Cell M10: a₃₁*b₁₁+a₃₂*b₂₁ becomes 3*1+1*4 and returns 7

Cell N8: a₁₁*b₁₂+a₁₂*b₂₂ becomes 0*2+1*-5 and returns -5

Cell N9: a₂₁*b₁₂+a₂₂*b₂₂ becomes -4*2+0*-5 and returns -8

Cell N10: a₃₁*b₁₂+a₃₂*b₂₂ becomes 3*2+1*-5 and returns 1

Cell O8: a₁₁*b₁₃+a₁₂*b₂₃ becomes 0*3+1*-6 and returns -6

Cell O9: a₂₁*b₁₃+a₂₂*b₂₃ becomes -4*3+0*-6 and returns -12

Cell O10: a₃₁*b₁₃+a₃₂*b₂₃ becomes 3*3+1*-6 and returns 3

This article shows you how to find a set of numbers which adds up to a sum you specify:

Excelxor is such a great website for inspiration, I am really impressed by this post Which numbers add up to […]

### Cell ranges with different number of rows and columns, example 2

Array1 (B2:D3) has **2** rows and array2 (F2:G4) has **2** columns, the returning array has **2** rows and **2** columns.

**Array formula in cell range L8:M9:**

=MMULT(B8:D9,F8:G10)

Cell L8: a₁₁*b₁₁+a₁₂*b₂₁+a₁₃*b₃₁ becomes 1*0+2*-4+3*3 and returns 1

Cell L9: a₂₁*b₁₁+a₂₂*b₂₁+a₂₃*b₃₁ becomes 4*0+-5*-4+-6*3 and returns 2

Cell M8: a₁₁*b₁₂+a₁₂*b₂₂+a₁₃*b₃₂ becomes 1*1+2*0+3*1 and returns 4

Cell M9: a₂₁*b₁₂+a₂₂*b₂₂+a₂₃*b₃₂ becomes 4*1+-5*0+-6*1 and returns -2

### Calculate totals row-wise

This array formula returns an array containing the total from each row in cell range C3:E7.

The number of columns in the first cell range or array must be equal to the number of rows in the second cell range or array.

Cell range C3:E7 has 3 columns and array {1; 1; 1} has three rows. The resulting array has the same number of rows as the cell range and the same number of columns as the array, in this case the array has 5 rows and 1 column. To be able to add all numbers in I use value 1 in the array.

You can also create an array that grows automatically based on the cell range, named range or an Excel defined Table.

This formula demonstrates how to create the array in the second argument using a cell range:

Let me explain this formula, the COLUMN function returns the corresponding column numbers from a cell range.

COLUMN(C3:E7) returns {3, 4, 5}.

COLUMN(C3:E7)^0

becomes

{3, 4, 5}^0

and returns {1, 1, 1}. Any number (except zero) to the power of 0 (zero) returns 1. This array has values distributed across columns, we need them transposed row-wise.

TRANSPOSE(COLUMN(C3:E7)^0)

becomes

TRANSPOSE({1, 1, 1}) and returns {1; 1; 1}.

This formula demonstrates how to create the array using a named range:

*named_range*, TRANSPOSE(COLUMN(

*named_range*)^0))

This formula demonstrates how to create the array using a reference to an Excel Table:

If you are an Excel 365 subscriber you can use the newly added SEQUENCE function:

This post demonstrates how to refresh a scoreboard instantly using the MMULT function:

This article demonstrates a scoreboard, displayed to the left, that sorts contestants based on total scores and refreshes instantly each […]

### Calculate totals column-wise

=MMULT({1, 1, 1, 1, 1}, C3:E7)

This article demonstrates how to search a data set with multiple strings using the MMULT function:

Search each column for a string each and return multiple records – OR logic

RU asks: Can you please suggest if i want to find out the rows with fixed value in "First Name" […]

Search each column for a string each and return multiple records – OR logic

### Articles with the 'MMULT' Function

The following 9 articles have formulas that contain the MMULT function.

Excelxor is such a great website for inspiration, I am really impressed by this post Which numbers add up to […]

This article demonstrates a scoreboard, displayed to the left, that sorts contestants based on total scores and refreshes instantly each […]

Extract records containing digits [Formula]

Liam asks: Hello Oscar, What code is needed to cause cells in Columns F - I to fill with the […]

Count overlapping days in multiple date ranges

The MEDIAN function lets you count overlapping dates between two date ranges. If you have more than two date ranges […]

Count overlapping days across multiple date ranges

This post demonstrates a formula in cell D16 that counts overlapping dates across multiple date ranges. The date ranges are […]

Working with overlapping date ranges

Today's blog post is about date ranges, the techniques demonstrated here can also be applied to time or other numerical […]

Count cells containing text from list

The array formula in cell F3 counts cells in column B that contains at least one of the values in […]

The formula in cell B17 counts rows in cell range B3:D17 when at least one cell per row contains data. […]

Get date ranges from a schedule

The above picture shows you two formulas that extract names (column B) and date ranges (column C and D) based […]

### Functions in 'Math and trigonometry'

The MMULT function function is one of many functions in the 'Math and trigonometry' category.

Converts negative numbers to positive numbers, in other words, the ABS function removes the sign. Excel Function Syntax ABS(number) Arguments […]

The ACOS function calculates the arccosine, or inverse cosine, of a number. Formula in cell C3: =ACOS(B3) Excel Function Syntax […]

The ACOSH function calculates the inverse hyperbolic cosine of a number. Formula in cell C3: =ACOSH(B3) Excel Function Syntax ACOSH(number) […]

The ACOT function calculates the inverse cotangent of a number. The returned angle is given in radians from 0 (zero) […]

The ACOTH function calculates the inverse hyperbolic cotangent of a number. Formula in cell C3: =ACOTH(B3) Excel Function Syntax ACOTH(number) […]

How to use the AGGREGATE function

The AGGREGATE function allows you to calculate different specific functions to a list or database. A special AGGREGATE function feature […]

The ASIN function calculates the arcsine of a number. The angle is in radians and is between -pi/2 to pi/2. =ASIN(B3) Excel […]

The ASINH function calculates the inverse hyperbolic sine of a number. =ASINH(B3) Excel Function Syntax ASINH(number) Arguments number Required. Any […]

The ATAN function calculates the arctangent of a number. The returned angle is in radians between -pi/2 to pi/2. =ATAN(B3) Excel […]

The ATAN2 function calculates the arctangent of an angle using specific x- and y-coordinates. The returned angle is in radians […]

The ATANH function calculates the inverse hyperbolic tangent of a number. =ATANH(B3) Excel Function Syntax ATANH(number) Arguments number Required. Must be […]

The BASE function converts a number into a text representation with a given radix (base). Formula in cell C3: =BASE(10, […]

How to use the CEILING function

The CEILING function rounds a number up to its nearest multiple. The number is rounded down if both the number […]

How to use the COMBIN function

The COMBIN function returns the number of combinations for a specific number of elements out of a larger number of […]

How to use the COMBINA function

The COMBINA function calculates the number of combinations for a given number of elements from a larger group of elements. Formula in […]

The COS function calculates the cosine of an angle. Formula in cell C3: =COS(B3) Excel Function Syntax COS(number) Arguments number […]

The COSH function calculates the hyperbolic cosine of a number. Formula in cell C3: =COSH(B3) Excel Function Syntax COSH(number) Arguments […]

The COT function calculates the cotangent of an angle specified in radians. Formula in cell C3: =COT(B3) Excel Function Syntax […]

The COTH function calculates the hyperbolic cotangent of a hyperbolic angle. The function has been available since Excel 2013. Formula […]

The CSC function calculates the cosecant of an angle (radians). The CSC function returns the same value as 1/SIN(number). Formula in […]

How to use the DECIMAL function

The DECIMAL function converts a text representation of a number in a given base into a decimal number. Formula in […]

How to use the DEGREES function

The DEGREES function calculates degrees from radians. Formula in cell C3: =DEGREES(B3) Excel Function Syntax DEGREES(angle) Arguments angle Required. The […]

The EVEN function rounds a number up to the nearest even whole number. An even number is a number that […]

Returns e raised to the power of a number, e equals 2.71828182845904. Example, e^2 equals 7.389056099 Formula in cell C3: […]

The FACT function returns the factorial of a number. Formula in cell C3: =FACT(B3) Example, 3! = 3*2*1 = 6 […]

How to use the FACTDOUBLE function

The FACTDOUBLE returns the double factorial of a number. Formula in cell C3: =FACTDOUBLE(B3) Excel Function Syntax FACTDOUBLE(number) Arguments number […]

How to use the FLOOR.MATH function

The FLOOR.MATH function rounds a number down to the nearest integer or to the nearest multiple of significance. Formula in […]

How to use the FLOOR.PRECISE function

The FLOOR.PRECISE function rounds a number down to the nearest integer or nearest multiple of significance. Excel Function Syntax FLOOR.PRECISE(number, […]

The GCD calculates the greatest common divisor that divides all given arguments without a remainder. Formula in cell D3: =GCD(B3:B4) Excel […]

Removes the decimal part from positive numbers and returns the whole number (integer) except negative values are rounded down to […]

The LCM function calculates the least common multiple. The least common multiple is the smallest positive integer that is a […]

The LN function calculates the natural logarithm of a number. Natural logarithms are based on the constant e. Formula in […]

The LOG function calculates the logarithm of a number to a specific base. Formula in cell C3: =LOG(10) Excel Function […]

The LOG10 function calculates the logarithm of a number using the base 10. Formula in cell C3: =LOG10(B3) Excel Function […]

How to use the MINVERSE function

The MINVERSE function calculates the inverse matrix for a given array. This function is useful for solving equations with multiple variables. […]

The MMULT function calculates the matrix product of two arrays, an array as the same number of rows as array1 and […]

The Mod function returns the remainder after a number is divided by divisor. The Mod function is short for the Modulo […]

How to use the MROUND function

The MROUND function calculates a number rounded to a given multiple. Formula in cell D3: =MROUND(B3,C3) Excel Function Syntax MROUND(number, […]

How to use the MULTINOMIAL function

The MULTINOMIAL function calculates the ratio of the factorial of a sum of values to the product of factorials. Formula […]

The MUNIT function calculates the identity matrix for a given dimension. Array formula in cell B2: =MUNIT(3) The formula above returns an […]

The PI function returns the number pi (¶). Formula in cell B3: =PI() Excel Function Syntax PI() Arguments PI function […]

The POWER function calculates a number raised to a power. Excel Function Syntax POWER(number, power) Arguments number Required. The number […]

How to use the PRODUCT function

The PRODUCT function returns the product of the numbers given in the argument. Formula in cell D3: =PRODUCT(B3:C3) Excel Function […]

How to use the RADIANS function

The RADIANS function converts degrees to radians. Formula in cell C3: =RADIANS(B3) Excel Function Syntax RADIANS(angle) Arguments angle Required. The […]

The RAND function calculates a random real number greater than or equal to 0 and less than 1. The function […]

How to use the RANDBETWEEN function

Returns a random whole number between the numbers you specify. This function is volatile meaning a new random number is […]

How to use the ROUNDDOWN function

The ROUNDDOWN function calculates a number rounded down based on the number of digits to which you want to round […]

How to use the ROUNDUP function

The ROUNDUP function calculates a number rounded up based on the number of digits to which you want to round […]

The SEC function calculates the secant of an angle. Formula in cell E3: =SEC(B3) Excel Function Syntax SEC(number) Arguments number […]

The SECH function calculates the hyperbolic secant of an angle. Formula in cell C3: =SECH(B3) Excel Function Syntax SECH(number) Arguments […]

How to use the SERIESSUM function

The SERIESSUM function calculates the sum of a power series based on the following formula: SERIESSUM(x, n, m, a) = […]

The SIGN function returns the sign of a number. 1 for a positiv number, 0 (zero) for a 0 (zero) […]

The SIN function calculates the sine of an angle. Formula in cell C3: =SIN(B3) Excel Function Syntax SIN(number) Arguments number […]

The SINH function calculates the hyperbolic sine of a number. Formula in cell C3: =SINH(B3) Excel Function Syntax SINH(number) Arguments […]

The SQRT function calculates the positive square root. Formula in cell C3: =SQRT(B3) Excel Function Syntax SQRT(number) Arguments number Required. […]

The SUM function in Excel allows you to add values, the function returns the sum in the cell it is […]

The SUMIF function sums values based on a condition. The condition can be applied to the values being summed or […]

How to use the SUMIFS function

The SUMIFS function in cell D11 adds numbers from column D based on criteria applied to column B and C. […]

How to use the SUMPRODUCT function

The SUMPRODUCT function calculates the product of corresponding values and then returns the sum of each multiplication.

The SUMSQ function calculates the sum of the squares of the arguments. Formula in cell D3: =SUMSQ(B3:B5) 2^2 = 4, […]

How to use the SUMX2MY2 function

The SUMX2MY2function calculates the sum of the difference of squares of corresponding values in two arrays. Formula in cell F3: […]

How to use the SUMX2PY2 function

The SUMX2PY2 function calculates the sum of the sum of squares of corresponding values in two arrays. The sum of […]

How to use the SUMXMY2 function

The SUMXMY2 function calculates the sum of squares of differences of corresponding values in two arrays. Formula in cell F3: […]

The TAN function calculates the tangent of an angle. Formula in cell C3: =TAN(B3) Excel Function Syntax TAN(number) Arguments number […]

The TANH function calculates the hyperbolic tangent of a number. Formula in cell C3: =TANH(B3) Excel Function Syntax TANH(number) Arguments number […]

The TRUNC function removes the fractional part of the number to an integer. Formula in cell C3: =TRUNC(B3) Excel Function […]

Learn how to use the SUBTOTAL function

The picture above shows row 4 and row 8 hidden, the SUM argument 9 sums all values in C3:C11 whereas […]

The quotient function returns the integer portion of a division. Example, 5/2 = 2.5. The integer is 2. Excel Function […]

### 4 Responses to “How to use the MMULT function”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

A great write-up as usual Oscar. Do you have any use cases to share? In 10 years of using Excel I can only think of one time where it occurred to me to use MMULT, and I can't put my finger on it now.

Hi Oscar,

Thanks for taking the request..

@ Andy.. & @Oscar

In addition.. to the previous discussion.. :)

Check the attached file.. there are few sample use of MMULT..

https://dl.dropboxusercontent.com/u/78831150/Excel/Sample%20use%20of%20MMULT.xlsx

https://dl.dropboxusercontent.com/u/78831150/Excel/Sample%20use%20of%20MMULT.jpg

https://postimg.org/image/tn0pfedvl/

Regards,

Deb

Andy,

Thank you. I have no examples to share, yet. I searched excelforum.com and found a few posts but nothing really sensational.

I googled "use of matrix multiplication" and found some practical examples in math and physics.

Deb,

Thank you for your contribution!

Formula #1=SUM(MMULT(B2:C15;{1;-1}))

MMULT(B2:C15;{1;-1}) returns {29; 77; -1; 27; 69; 3; -3; 32; 54; -67; -65; -46; 21; -67}

equivalent to =B2:B15-C2:C15

So this formula does the same thing: =SUM(B2:B15-C2:C15)

Formula #2=SUM(MMULT(B2:C15;{1;1})) sums of all values in B2:C15.

It is equivalent to this formula =SUM(B2:C15)

Good examples, I am beginning to understand. But I want to do someting creative and unique with the MMULT function, something that is not possible with other function or at least complicated to accomplish.

Thanks again for sharing!

[…] Mmult function […]