Solved: If text then perform this, if not then skip.
Hi All,
I have a line of code that it suppouse to subtotal but when it tries to subtotal it tell me that the the command can not be completed using the specified range, so what I think, I have to do is bypass the subtotal if there is no data to subtotal, could somebody :help me with this.
[VBA]
'Subtotal code
Range("E1").Select
Selection.RemoveSubtotal
Range("E1").Select
Selection.Subtotal GroupBy:=23, Function:=xlCount, TotalList:=Array(23), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=23, Function:=xlSum, TotalList:=Array(20), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
[/VBA]
Please help
Julio
Solve:If text then perform this, if not then skip.
Sorry for the inconvineance.
I figure it out, like I said, I am just getting my feet wet in learning VBA.
This is what I wanted.
[VBA]
'Subtotal code
If Range("A2") > 0 Then
Range("E1").Select
Selection.RemoveSubtotal
Range("E1").Select
Selection.Subtotal GroupBy:=23, Function:=xlCount, TotalList:=Array(23), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Selection.Subtotal GroupBy:=23, Function:=xlSum, TotalList:=Array(20), _
Replace:=False, PageBreaks:=False, SummaryBelowData:=True
End If
[/VBA]