#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default subtotals

Hi everyone,

Is there any function in VBA that can determine whether subtotals are
displayed on a particular sheet?
Something like aSheet.HasSubtotals that returns True or False would be nice.
It doesn't exist, though.

In addition, a macro of mine contains the following code, that cleans up a
certain worksheet before filling the sheet with new data:

intOutputRij = 4
Set shtOutput = ActiveWorkbook.Sheets("Output")
With shtOutput.Range("A" & Format(intOutputRij) & ":IV65536")
.ClearContents ' remove old data
.Font.Bold = False
.Range("A:A").RemoveSubtotal ' error 1004 when there's no subtotal
End With

Error 1004 is trapped with a Resume Next. The RemoveSubtotal method doesn't
work as nicely as it should. Sometimes I do get a clean worksheet, but
sometimes it leaves the subtotals untouched, resulting in about 7 or more
levels to collapse/expand, or in a movement down, allowing me to
collapse/expand empty rows.

Any suggestions?

Thank you,
Cooz

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default subtotals

or just remove the outline to clean data

With Range("A:A").Select
Selection.ClearOutline
End With


On Oct 19, 1:59*pm, Cooz wrote:
Hi everyone,

Is there any function in VBA that can determine whether subtotals are
displayed on a particular sheet?
Something like aSheet.HasSubtotals that returns True or False would be nice.
It doesn't exist, though.

In addition, a macro of mine contains the following code, that cleans up a
certain worksheet before filling the sheet with new data:

* * intOutputRij = 4
* * Set shtOutput = ActiveWorkbook.Sheets("Output")
* * With shtOutput.Range("A" & Format(intOutputRij) & ":IV65536")
* * * * .ClearContents ' remove old data
* * * * .Font.Bold = False
* * * * .Range("A:A").RemoveSubtotal ' error 1004 when there's no subtotal
* * End With

Error 1004 is trapped with a Resume Next. The RemoveSubtotal method doesn't
work as nicely as it should. Sometimes I do get a clean worksheet, but
sometimes it leaves the subtotals untouched, resulting in about 7 or more
levels to collapse/expand, or in a movement down, allowing me to
collapse/expand empty rows.

Any suggestions?

Thank you,
Cooz


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
Subtotals function offset subtotals summary TimkenSteve Excel Programming 2 September 19th 06 01:07 PM
Subtotals: Nested subtotals below higher subtotal RobN Excel Discussion (Misc queries) 1 July 20th 06 09:04 PM
Problem with nested subtotals, placing secondary subtotals BELOW . Dawn Cameron Excel Discussion (Misc queries) 1 June 3rd 05 10:13 PM


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