Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Subtotals problem: Excel 2003 (not, AFAIK, the nested subtotals bug) AndyCotgreave Excel Discussion (Misc queries) 3 October 24th 07 11:32 AM
Original subtotals should not be within nested subtotals in excel Mirage Excel Worksheet Functions 1 June 6th 07 01:37 AM
How do I copy an outline w/ subtotals & paste just the subtotals av Excel Discussion (Misc queries) 1 June 20th 05 11:35 PM
Problem with nested subtotals, placing secondary subtotals BELOW . Dawn Cameron Excel Discussion (Misc queries) 1 June 3rd 05 10:13 PM
why are nested subtotals coming out below outer subtotals? Hendy Excel Worksheet Functions 2 January 18th 05 08:09 PM


All times are GMT +1. The time now is 06:49 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"