PDA

View Full Version : Solved: Subtotal needs modifying vba



Shazam
08-31-2006, 01:42 PM
I have a code that acts like a subtotal. But I would like it to be modified. Please look at the small example attachment. It will give you a better visual sense.



Sub Subtotal()

For Each NumRange In Columns("A").SpecialCells(xlCellTypeConstants, 23).Areas
SumAddr = NumRange.Address(False, False)
NumRange.Offset(NumRange.Count, 0).Resize(1, 2).Formula = "=SUM(" & SumAddr & ")"
c = NumRange.Count
Next NumRange
NoData:

End Sub

Bob Phillips
08-31-2006, 03:37 PM
Sub Subtotal()

For Each NumRange In Columns("A").SpecialCells(xlCellTypeConstants, _
xlTextValues + xlErrors + xlLogical + xlNumbers).Areas
SumAddr = NumRange.Address(False, False)
c = NumRange.Count
If c > 1 Then
With NumRange.Offset(c, 0).Resize(1, 2)
.Formula = "=SUM(" & SumAddr & ")"
.Font.Bold = True
End With
End If
Next NumRange
NoData:

End Sub

Shazam
08-31-2006, 05:45 PM
Thank You so much xld it works great.:hi: