P
Paul D. Simon
I'm trying to create a button on a worksheet that will "toggle"
Subtotal on and off. I came up with this code, but it doesn't work.
The 2nd line (If Selection.SubTotal = False Then) is the offending
line. What would be the correct syntax?
Sub SubtotalOnOff()
Range("A8").Select
If Selection.SubTotal = False Then
Selection.SubTotal GroupBy:=3, Function:=xlSum,
TotalList:=Array(5, 6), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Else
Selection.RemoveSubtotal
End If
End Sub
Subtotal on and off. I came up with this code, but it doesn't work.
The 2nd line (If Selection.SubTotal = False Then) is the offending
line. What would be the correct syntax?
Sub SubtotalOnOff()
Range("A8").Select
If Selection.SubTotal = False Then
Selection.SubTotal GroupBy:=3, Function:=xlSum,
TotalList:=Array(5, 6), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Else
Selection.RemoveSubtotal
End If
End Sub