```
id a b c
1 0 0 0
1 0 0 0
2 0 0 0
2 0 0 0
3 1 2 3
3 0 0 1
```

Given the above matrix, I want to create a new matrix, which sums the numbers within the first matrix for a given id in a given year (a,b or c). So for the above, it should look like:

```
1 2 3
a 0 0 1
b 0 0 2
c 0 0 4
```

Can anyone see what to do?

Try using SUMPRODUCT rather than SUMIFS, e.g.

`=SUMPRODUCT(B2:D7,(B1:D1="a")*(A2:A7=1))`

### Answer：

The formula solution given in the other responses will work well when data headings are already in place and the data range is not too large.

A pivot table creates the row and column headings for you and will update as new data is added when you click the Refresh Button, it’s also significantly quicker when the data range is large.

**Steps**

A) Choose `Insert | Table`

for your data range, and give it a suitable name, the default is *Table1*

B) Access the PivotTable wizard via the shortcut `Alt+D+P`

(this is not on the default menus).

```
1) Multiple Consolidation Ranges
2a) I will Create the Page Fields
2b) Range: Table1[#All] Page Fields: 0
2c) Existing Worksheet: $A$7
```

C) Click Finish, switch Row and column fields and turn off totals and autoformatting

### Answer：

I suggest that you try solving that problem with pivot tables.

Here are 2 links that you might use to learn that feature:

http://www.cpearson.com/excel/pivots.htm

http://www.youtube.com/watch?v=7zHLnUCtfUk

The only drawback with Pivots is that if the size of the source range changes, the Pivot will not adjust automatically. So once you managed to solve your initial problem and understand the power of Pivot Tables, I suggest that you use a Dynamic Named Range as the source of your Pivot.

Edit:

I feel that barry houdini’s solution is simpler. I reproduced it below (with all credit belonging to him!)

Tags: excelexcel