Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Adding a row to a subtotalled range

I have a spreadsheet that contains sales values for each month. As there can be more than one value for a month I am using the subtotal function to aggregate the sales to give me twelve values (one for each month). The spreadsheet is maintained on an ongoing basis, so new entries are added from time to time. The data range also has an auto filter so that I can select the records for any particular month if needed.

Currently, February only has one record. After applying the subtotal function to the range, I have added a second record for February, but the subtotal does not update. I am adding the second record by inserting a row and entering the values. However, the subtotal does not update itself irrespective of whether I add the row before or after the existing record.

If a month contains more than one record to begin with, I can insert a third row in between the two existing records and the subtotal will update automatically. The problem is specific to only having one record when the subtotal is set up in the first instance.

Example:

Month Sales($)
Jan 100
Jan 150
Jan 100
Jan Total 350
Feb 250
Feb Total 250
Mar 120
Mar 140
Mar Total 260

In the above example, The Feb Subtotal will not automatically update no matter where I insert a second record for Feb.

Help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Adding a row to a subtotalled range

Mickey

when you add subtotals it generates a formula, something like: =SUBTOTAL(9,B6:B6)

Note that this includes the range that is being subtotalled. So, adding a row above or below won't change that formula.

You'll need to remove the subtotals and add them again.

In code

Sub Macro1()
Selection.RemoveSubtotal
Selection.Subtotal GroupBy:=1, _
Function:=xlSum, _
TotalList:=Array(2), _
Replace:=True, _
PageBreaks:=False, _
SummaryBelowData:=True
End Sub

This was generated by recording the manual actions.

Regards

Trevor


"Mickey Mouse" <@ wrote in message ...
I have a spreadsheet that contains sales values for each month. As there can be more than one value for a month I am using the subtotal function to aggregate the sales to give me twelve values (one for each month). The spreadsheet is maintained on an ongoing basis, so new entries are added from time to time. The data range also has an auto filter so that I can select the records for any particular month if needed.

Currently, February only has one record. After applying the subtotal function to the range, I have added a second record for February, but the subtotal does not update. I am adding the second record by inserting a row and entering the values. However, the subtotal does not update itself irrespective of whether I add the row before or after the existing record.

If a month contains more than one record to begin with, I can insert a third row in between the two existing records and the subtotal will update automatically. The problem is specific to only having one record when the subtotal is set up in the first instance.

Example:

Month Sales($)
Jan 100
Jan 150
Jan 100
Jan Total 350
Feb 250
Feb Total 250
Mar 120
Mar 140
Mar Total 260

In the above example, The Feb Subtotal will not automatically update no matter where I insert a second record for Feb.

Help!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Adding a row to a subtotalled range

One of the things that Excel's Subtotal function (Spreadsheet side from the
Data menu) is doing, setting up ranges for each of the sub totals, and given
how formula works with ranges, if you insert a row within the range, the
formula will adjust automatically, but if you don't insert within the range,
it won't automatically adjust, thus with your 1 row formula range, it would
not be possible for it to automatically adjust cause the row above and the
row below are both outside of the 1 row range. Given that, you will need to
manually adjust the subtotal formula to include both rows.

--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Mickey Mouse" <@ wrote in message
...
I have a spreadsheet that contains sales values for each month. As there
can be more than one value for a month I am using the subtotal function to
aggregate the sales to give me twelve values (one for each month). The
spreadsheet is maintained on an ongoing basis, so new entries are added from
time to time. The data range also has an auto filter so that I can select
the records for any particular month if needed.

Currently, February only has one record. After applying the subtotal
function to the range, I have added a second record for February, but the
subtotal does not update. I am adding the second record by inserting a row
and entering the values. However, the subtotal does not update itself
irrespective of whether I add the row before or after the existing record.

If a month contains more than one record to begin with, I can insert a third
row in between the two existing records and the subtotal will update
automatically. The problem is specific to only having one record when the
subtotal is set up in the first instance.

Example:

Month Sales($)
Jan 100
Jan 150
Jan 100
Jan Total 350
Feb 250
Feb Total 250
Mar 120
Mar 140
Mar Total 260

In the above example, The Feb Subtotal will not automatically update no
matter where I insert a second record for Feb.

Help!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a range Josh Excel Discussion (Misc queries) 1 November 2nd 09 11:15 PM
Trouble sorting a subtotalled list Coach Ron Excel Discussion (Misc queries) 0 February 25th 09 07:48 PM
Printing a subtotalled worksheet rj shoe[_2_] Excel Discussion (Misc queries) 4 September 1st 08 08:36 PM
Sort a Subtotalled List? Rich Excel Discussion (Misc queries) 9 June 25th 05 11:59 AM
How to copy subtotalled cells to a new worksheet (in a macro), wi. LJB Excel Discussion (Misc queries) 2 June 23rd 05 02:00 AM


All times are GMT +1. The time now is 04:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"