macro excel subtotal in subtotal

G

GBO

For a sub total in another subtotal I'm look ing for the second
selection. at the moment I'm using this code but this takes very long
(it repeats 80 times for 140.000 rows in total)

Does anyone have a sugestion tot select the data my second subtotal

' first selection

Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Subtotal GroupBy:=19, Function:=xlSum,
TotalList:=Array(13, 17) _
, Replace:=True, PageBreaks:=False, SummaryBelowData:=True

' second selection

Cells.Select

Selection.Subtotal GroupBy:=6, Function:=xlSum,
TotalList:=Array(13, 17), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
 
D

Dave Peterson

You may find creating a pivottable is quicker.


For a sub total in another subtotal I'm look ing for the second
selection. at the moment I'm using this code but this takes very long
(it repeats 80 times for 140.000 rows in total)

Does anyone have a sugestion tot select the data my second subtotal

' first selection

Range("A1").Select

Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

Selection.Subtotal GroupBy:=19, Function:=xlSum,
TotalList:=Array(13, 17) _
, Replace:=True, PageBreaks:=False, SummaryBelowData:=True

' second selection

Cells.Select

Selection.Subtotal GroupBy:=6, Function:=xlSum,
TotalList:=Array(13, 17), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Subtotal Formatting 2
Subtotal macro in each worksheet 13
Subtotal Macro Help 2
Subtotal by VBA 5
Subtotal function 2
subtotal question 1
Subtotal problem/conflict 1
Editing a macro 5

Top