# Subtotal and running/cumulative total!

#### rahul25

##### New Member
Loacation Name Sales Comm
252 ABC 100 12.5
252 CCC 100 12.5
252 DDD 100 12.5
300 EEE 100 12.5
300 FFF 100 12.5
500 GGG 100 12.5
500 HHH 100 12.5
500 KKK 100 12.5

Is there any way to get the subtotal and running/cumulative total in each change of location number as under:

Loacation Name Sales Comm
252 ABC 100 12.5
252 CCC 100 12.5
252 DDD 100 12.5
252 total
Cum total
300 EEE 100 12.5
300 FFF 100 12.5
252 total
Cum total
500 GGG 100 12.5
500 HHH 100 12.5
500 KKK 100 12.5
252 total
Cum total
Grand Total

### Excel Facts

Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

#### XLGibbs

##### Well-known Member
G2 copied down
=SUMPRODUCT(--(\$A\$2:\$A\$9=F2),\$D\$2:\$D\$9)

H2 copied down
=SUM(\$G\$2:G2)

Ihope this gets you started
Book1
ABCDEFGH
1SUBRUNNING
2252ABC10012.525237.537.5
3252CCC10012.53002562.5
4252DDD10012.550037.5100
5300EEE10012.5
6300FFF10012.5
7500GGG10012.5
8500HHH10012.5
9500KKK10012.5
Sheet1

#### rahul25

##### New Member
Sorry I forgot to mention that I need VBA code which will give me subtotal and running total just in the rows within data area not somewhere else.

#### XLGibbs

##### Well-known Member
Yes, that certainly would have been useful information...has to be code?

There are many alternative means via formula, pivot table, or even using the subtotal function....

##### MrExcel MVP
Gibbs said:
G2 copied down
=SUMPRODUCT(--(\$A\$2:\$A\$9=F2),\$D\$2:\$D\$9)

H2 copied down
=SUM(\$G\$2:G2)

...

Whenever there is a single condition, the faster SumIf will suffice:

=SUMIF(\$A\$2:\$A\$9,F2,\$D\$2:\$D\$9)

Replies
9
Views
182
Replies
1
Views
52
Replies
10
Views
817
Replies
3
Views
2K
Replies
10
Views
504