Could anyone please help me in sorting why the below code does not run in Office 2010. It gives an error "Subtotal Method of Range Class failed" and the line of error is,
Selection.Subtotal GroupBy:=9, Function:=xlSum, TotalList:=Array(12), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
VB:
Sub Macro()
Columns("L:L").Select
Selection.Insert Shift:=xlToRight
Range("L1").Select
ActiveCell.FormulaR1C1 = "Name"
Range("L2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-5]=""s"",-RC[-1],RC[-1])"
Selection.AutoFill Destination:=Range("L2:L2980")
Range("L2:L2980").Select
Columns("K:L").Select
Selection.Style = "Comma"
Range("I7").Select
Range("A1:T2980").Sort Key1:=Range("I7"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Subtotal GroupBy:=9, Function:=xlSum, TotalList:=Array(12), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
End Sub
Bookmarks