Subtotal Calculation

gderricksmith

New Member
Joined
Mar 30, 2011
Messages
6
Hello all, and thank you in advance for any help given.
I have 300 - 400 row sheets that I get every week that i need to separate chunks of rows (by dates), insert a blank row, and calculate the subtotal.
Below is an example of what the information looks like before it is subtotaled

Date Total
30-Jan 5
30-Jan 10
30-Jan 11
30-Jan 8
30-Jan 20
6-Feb 5
6-Feb 1
6-Feb 2
6-Feb 8
13-Feb 3
13-Feb 1
13-Feb 1
13-Feb 5
20-Feb 5
20-Feb 14
20-Feb 14


And here is what I need it to look like after the macro has been run

Date Total
30-Jan 5
30-Jan 10
30-Jan 11
30-Jan 8
30-Jan 20
54
6-Feb 5
6-Feb 1
6-Feb 2
6-Feb 8
16
13-Feb 3
13-Feb 1
13-Feb 1
13-Feb 5
10
20-Feb 5
20-Feb 14
20-Feb 14
33


I know this doesn't look good with the formatting in this text box, but I can send the file that I'm working on if you need more clarification. The Date is supposed to be Column A and the number beside it is Column B
Please Help!
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Probably the easiest way is to use the year function =year(cell with date) and then use excels subtotal tool under the data tab in.
 
Upvote 0
Thanks millhouse. I tried the year function but continue to get "2011" for every date in the sheet. Is there something that I'm missing here? Or is there any way to get the make a macro to auto outline by groups?

Thanks!
 
Upvote 0
If your dates are in column A and totals are in column B, enter in cell C2, =IF(A2=A1,B2+C1,B2) and fill down (you can hide this column), then in D2 enter, =IF(AND(A2=A1,A3=A2),"",IF(AND(A2=A1,A3<>A2),C2,"")) and fill down. This gives the results you are wanting and the other cells will be blank.
 
Upvote 0
My bad... Instead of the year function try the month function to get the number of the month, then you can sort and use the subtotal in excel. Also make sure your data is formatted as a date so that excel recogizes the data properly.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top