how to simply-fly this macro
i have recorded the macro while doing subtotal i want to simply-fly the process
1.Sorting should not be of specific range , it should be for full column range rows in data can increase or decrease ,column sorting order is ok .
2. There are 3 subtotal - for 1st subtotal only Grand Total must be there in the end for other 2 not required - how to remove
3. Color for all the 3 subtotal can be done
4.Subtotal is not delete after last subtotal
i have recorded the macro while doing subtotal i want to simply-fly the process
1.Sorting should not be of specific range , it should be for full column range rows in data can increase or decrease ,column sorting order is ok .
2. There are 3 subtotal - for 1st subtotal only Grand Total must be there in the end for other 2 not required - how to remove
3. Color for all the 3 subtotal can be done
4.Subtotal is not delete after last subtotal
Code:
Sub subtotal()
'
' subtotal Macro
'
'
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("12").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("12").Sort.SortFields.Add Key:=Range("B2:B80"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("12").Sort.SortFields.Add Key:=Range("D2:D80"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("12").Sort.SortFields.Add Key:=Range("F2:F80"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("12").Sort.SortFields.Add Key:=Range("H2:H80"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("12").Sort
.SetRange Range("A1:W80")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.subtotal GroupBy:=3, Function:=xlSum, TotalList:=Array(10, 11, 12 _
, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True, PageBreaks:=False, _
SummaryBelowData:=True
Selection.Copy
Application.Run "ASAPRunProc268"
Application.CutCopyMode = False
Selection.RemoveSubtotal
Selection.subtotal GroupBy:=5, Function:=xlSum, TotalList:=Array(10, 11, 12 _
, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True, PageBreaks:=False, _
SummaryBelowData:=True
Selection.Copy
Application.Run "ASAPRunProc268"
Application.CutCopyMode = False
Selection.RemoveSubtotal
Selection.subtotal GroupBy:=7, Function:=xlSum, TotalList:=Array(10, 11, 12 _
, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True, PageBreaks:=False, _
SummaryBelowData:=True
Selection.Copy
Application.Run "ASAPRunProc268"
Application.CutCopyMode = False
Selection.RemoveSubtotal
Range("A1").Select
End Sub