'Sum rows until customer number changes

How can I sum the rows of product sales 1-3, until the Customer Code changes? Then the next Customer sales should be summed up. There may be customers with only 1 or 2 products also.

enter image description here



Solution 1:[1]

If you have CustomerId in column A and Sales in column B, you could add an extra column C with formula:

=IF(A2=A1,C1+B2,B2)

And then drag it down.

Excel picture

Solution 2:[2]

This is exactly the reason why the subtotals feature has been invented. Hereby a screenshot (not in English, sorry):

enter image description here

Here is the URL of the official documentation.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hiibb
Solution 2 Dominique