Grup and subtotal in VBA
Hi,
first of all, you have to be sure that the list is sorted by the items
which should be grouped. In case, this is not already done, the
following piece of code helps:
Assume, the whole list is selected and the last active cell is on the
first cell of "store"
Selection.Sort Key1:=ActiveCell.Offset(0,4), Order1:=xlAscending,
Header:=xlNo, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
Then the grouping and subtotalling is done by
Selection.Subtotal GroupBy:=5, Function:=xlSum, TotalList:=Array(3, 4,
5), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
Good luck
Udo
Orhan schrieb:
Hi
What I need to do is to make in vba subtotal of a big list (19000 rows)
store val1 val2 val3 id name
MAGAZIN 1 (1) 42.00 45.45 34.46 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 1 (1) 18.64 34.80 10.60 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 1 (1) 27.00 47.50 12.92 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 1 (1) 26.90 42.00 8.40 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 1 (1) 45.53 70.00 13.29 123 BA ALC LICHIOR (123)
MAGAZIN 1 (1) 23.00 33.60 5.24 123 BA ALC LICHIOR (123)
MAGAZIN 2 (2) 9.80 15.20 2.98 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 2 (2) 21.50 33.00 6.23 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 2 (2) 77.11 56.00 36.34 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 2 (2) 32.77 59.20 16.98 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 2 (2) 6.30 9.70 1.85 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 2 (2) 45.53 70.00 13.29 123 BA ALC LICHIOR (123)
MAGAZIN 2 (2) 23.00 33.60 5.24 123 BA ALC LICHIOR (123)
I need to grup by store name and subtotal val1, val2, val3 by id
The result I want looks like this:
MAGAZIN 1 (1) 114.54 169.75 66.38 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 1 (1) 68.53 103.60 18.53 123 BA ALC LICHIOR (123)
MAGAZIN 2 (2) 147.48 173.10 64.38 119 BA ALC CONIAC, BRANDY (119)
MAGAZIN 2 (2) 68.53 103.60 18.53 123 BA ALC LICHIOR (123)
Any help apreciated!
|