Search code examples
arraysexcelexcel-formulaexcel-2010

How to sum across an array, based on matching to row and multiple columns in Excel?


I have an array where I am trying to sum values across multiple columns. The array looks like this:

Name Animal Animal Color Color
Jane 1 3 2
John 1 2 1

I am trying to create a table that looks like this:

Name Animal Color
Jane 1 5
John 3 1

Where I am summing across the columns, grouped by the row.

I have tried to do sum and index match, but it is only summing the first occurrence of the column, and not multiple columns. How do I go about doing this?


Solution

  • =SUMPRODUCT($B$2:$E$3*($A$2:$A$3=$A9)*($B$1:$E$1=B$8))

    enter image description here

    Note the use of $ to lock the row and/or column to not change when dragging the formula.