ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro excel subtotal in subtotal (https://www.excelbanter.com/excel-discussion-misc-queries/167789-macro-excel-subtotal-subtotal.html)

GBO

macro excel subtotal in subtotal
 
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

Dave Peterson

macro excel subtotal in subtotal
 
You may find creating a pivottable is quicker.



GBO wrote:

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


--

Dave Peterson

GBO

macro excel subtotal in subtotal
 
pivottable is not an option for the client


All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com