Home |
Search |
Today's Posts |
|
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the reply. I don't mind seeing multiple grand total liine,
what I minded was the fact that when the second subtotal executed, it only used part of the data and left 15% of the data hanging out on the other side of the second subtotal, thus creating garbage data. However, I was able to fix my problem by looking at other people's questions/answers dealing with subtotals and finding a way to reset the range. Here's what I ended up doing: ActiveWorkbook.Worksheets("WORKSHEET_A").Activate Set awks = ActiveSheet ' Which columns do I want subtotals for? intcol(1) = 1 intcol(2) = 2 intcol(3) = 4 intcol(4) = 6 With awks Cells.Select Selection.RemoveSubtotal For i = 1 To 4 ' Find the bottom non empty cell to reset the range to the whole selectionn lastrow = .Cells(.Rows.Count, "A").End(xlUp).row Set rng = .Range("a1:j" & lastrow) rng.Select ' If first time through, have replace be true (probably redundant) If i = 1 Then breplace = True Else breplace = False End If ' Do subtotal on group/column Selection.Subtotal GroupBy:=intcol(i), Function:=xlSum, _ TotalList:=Array(8, 9), Replace:=breplace, _ PageBreaks:=False, SummaryBelowData:=True Next ' Roll everything up .Outline.ShowLevels RowLevels:=5 .Outline.ShowLevels RowLevels:=4 .Outline.ShowLevels RowLevels:=3 .Outline.ShowLevels RowLevels:=2 End With Debra Dalgleish wrote in message ... Even if you create the second set of subtotals manually, you get a second grand total row. I don't think you can avoid the duplicates when you create the subtotals programmatically. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem with subtotal function | Excel Worksheet Functions | |||
Display Multiple Cells when Using Subtotal Function | Excel Discussion (Misc queries) | |||
function problem regarding cell range | Excel Worksheet Functions | |||
INTRICATE PROBLEM- How to find multiple text,excluding "H", in a multiple range of cells, then replacing 0 with another number in another cell | Excel Worksheet Functions | |||
Passing a Range to a Function Problem | Excel Programming |