You just need to make a few changes to the code sample you posted.
Quote:
quote:Sub Button1_Click()
Dim dblSum As Double
Range("B5").Select
Do Until IsEmpty(ActiveCell)
dblSum = ActiveCell.Offset(0, 1)
Do While ActiveCell = ActiveCell.Offset(1, 0)
dblSum = dblSum + ActiveCell.Offset(1, 1)
ActiveCell.EntireRow.Delete
Loop
ActiveCell.Offset(0, 1) = dblSum
ActiveCell.Offset(1, 0).Select
Loop
End Sub
|
Change your script to this:
Code:
Sub Button1_Click()
Dim dblSum As Double
Range("B5").Select
Do Until IsEmpty(ActiveCell)
dblSum = ActiveCell.Offset(0, 1)
Do While ActiveCell = ActiveCell.Offset(1, 0)
dblSum = dblSum + ActiveCell.Offset(1, 1)
' the following line was deleting the active row
' ActiveCell.EntireRow.Delete
Loop
' the following line places the subtotal in the last line for the item
ActiveCell.Offset(0, 2) = dblSum
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Darrell L. Embrey