Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle subtotals...
I'm trying to use the same macro to 'toggle' the sub-total function in
Excel. I can currently apply a subtotal to the selected data range, but I also want to remove all subtotals (if any exist) by using the same macro. Is there any poperty that will determine whether subtotals exist on a worksheet? Thanks, Bill. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle subtotals...
Try this. Uses fact that ordinary data rows' OutlineLevels become
greater than 1 when SubTotals applied. '------------------------------------------- Sub ApplySubtotals() ' Check a row known to be ordinary data If ActiveSheet.Rows(2).OutlineLevel = 1 Then ActiveSheet.Range("A1").Subtotal _ GroupBy:=1, Function:=xlSum, TotalList:=Array(2, 3, 4, 5), _ Replace:=True, PageBreaks:=False, SummaryBelowData:=True Else ActiveSheet.Range("A1").RemoveSubtotal End If End Sub '---------------------------------------------- Regards BrianB =========================================== billy-boy wrote in message ... I'm trying to use the same macro to 'toggle' the sub-total function in Excel. I can currently apply a subtotal to the selected data range, but I also want to remove all subtotals (if any exist) by using the same macro. Is there any poperty that will determine whether subtotals exist on a worksheet? Thanks, Bill. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Toggle subtotals...
Thanks. Worked out very well...
Bill. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Subtotals problem: Excel 2003 (not, AFAIK, the nested subtotals bug) | Excel Discussion (Misc queries) | |||
Original subtotals should not be within nested subtotals in excel | Excel Worksheet Functions | |||
How do I copy an outline w/ subtotals & paste just the subtotals | Excel Discussion (Misc queries) | |||
Problem with nested subtotals, placing secondary subtotals BELOW . | Excel Discussion (Misc queries) | |||
why are nested subtotals coming out below outer subtotals? | Excel Worksheet Functions |