Subtotal function
I have some VBA code that should subtotal a table based on the 1st column and then resubtotal on the second column. The problem I am having is that the second subtotal puts the "Section Total" label in the first column as well. Any ideas on what I am doing wrong? Thanks for the help: ColStart = 2 ColEnd = lvlColumn + 2 ReDim Columns(0 To (ColEnd - ColStart)) For i = ColStart To ColEnd Columns(i - ColStart) = i Next i ColSt = 2 ColEn = lvlColumn + 2 ReDim Columns2(0 To (ColEn - ColSt)) For n = ColSt To ColEn Columns2(n - ColSt) = n Next n With xlSheet.Range("A:ZZ") .Cells.Copy .Cells.PasteSpecial (xlPasteValues) .Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Columns, _ Replace:=True, PageBreaks:=False, SummaryBelowData:=True .Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Columns2, _ Replace:=False, PageBreaks:=False, SummaryBelowData:=True End With |
All times are GMT +1. The time now is 07:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com