AbhishekJain
New Member
- Joined
- Dec 30, 2016
- Messages
- 1
Hi!!
I am looking for a code which will add subtotals in column M,N,O, Q,R,S and W,X,Y.
First I am trying to sort the transactions in column Z..
'Sort as per Type of transaction
Dim Wb1 As Workbook
Dim ws1 As Worksheet
Range("A1:AF20000").Sort _
Key1:=Range("Z1"), Header:=xlYes
' Adding subtotals
Sub ApplySubTotals()
Set ws1 = ThisWorkbook.Sheets("Purchase")
ws1.Range(ws1.UsedRange.Address).Select
Range("Z1").Activate
Selection.Subtotal GroupBy:=26, Function:=xlSum, TotalList:=Array(13, 14, _
15, 17, 18, 19, 23, 24, 25), Replace:=True, PageBreaks:=False, SummaryBelowData _
:=True
End Sub
The code does not seem to work always.. Any suggestions to improve my codes?
I am looking for a code which will add subtotals in column M,N,O, Q,R,S and W,X,Y.
First I am trying to sort the transactions in column Z..
'Sort as per Type of transaction
Dim Wb1 As Workbook
Dim ws1 As Worksheet
Range("A1:AF20000").Sort _
Key1:=Range("Z1"), Header:=xlYes
' Adding subtotals
Sub ApplySubTotals()
Set ws1 = ThisWorkbook.Sheets("Purchase")
ws1.Range(ws1.UsedRange.Address).Select
Range("Z1").Activate
Selection.Subtotal GroupBy:=26, Function:=xlSum, TotalList:=Array(13, 14, _
15, 17, 18, 19, 23, 24, 25), Replace:=True, PageBreaks:=False, SummaryBelowData _
:=True
End Sub
The code does not seem to work always.. Any suggestions to improve my codes?