Subtotal and running/cumulative total!

R

rahul25

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

This is the data I got from external databae query. Is there any VBA
code to add subtotal and also running total in the rows after evr
location number changes. I mean, If I run the vba macro It will inser
two rows after every location changes. One row for subtotal for th
each locaion and in the next row will be the cumulative totals for al
location upto that point.:eek
 
G

Guest

Public Sub Get_Totals()

Dim rw As Long
Dim total As Double
rw = 2
Do Until Cells(rw, "A") = ""
If Cells(rw, "A") = Cells(rw + 1, "A") Then
total = total + Cells(rw, "D")
Else
Cells(rw, "E") = total + Cells(rw, "D")
total = 0
End If
rw = rw + 1
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Need help with multi-row filter/sort 1
Combining Data 1
Copy & paste range 4
Another Running Totals Problem 9
Combine consecutive Rows 2
Combine consecutive Rows 1
Excel Issue 1
EXCEL issue 3

Top