Jagdev Singh
Active Member
Hi Experts,
I have recorded a macro which adds and remove subtotal from multiple sheets. Can we do it with VBA code.
Add subtotal code
Remove subtotal:
Regards,
JD
I have recorded a macro which adds and remove subtotal from multiple sheets. Can we do it with VBA code.
Add subtotal code
Code:
Sheets("EL Listing").Activate
Range("B5").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(10, 11, 12 _
), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Sheets("PL Listing").Activate
Range("B5").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(10, 11, 12 _
), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Sheets("Med Mal Listing").Activate
Range("B5").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(10, 11, 12 _
), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Sheets("Legal Expense Listing").Activate
Range("B5").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(10, 11, 12 _
), Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Application.Calculation = xlCalculationAutomatic
Sheets("PDBI Listing").Activate
Range("B5").Select
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(7, 8, 9), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Remove subtotal:
Code:
Sheets("EL Listing").Select
Selection.RemoveSubtotal
Sheets("PL Listing").Select
Selection.RemoveSubtotal
Sheets("Med Mal Listing").Select
Selection.RemoveSubtotal
Sheets("PDBI Listing").Select
Selection.RemoveSubtotal
Sheets("Legal Expense Listing").Select
Selection.RemoveSubtotal
JD