Hi, I have a worksheet with names and numbers. I want to insert a row when the name is different (which I have a macro for) and sum up the numbers for that name right in that blank row. I have post up the macro I found on this site and what I tried to do. Thanks for reading.
The codes in the brackets trying to be bold are what I put in trying to make it work. Basically, I was trying to add up each of the numbers when I skip to the next row then display the sum when I insert a new row.
The names are in column A and the numbers are in column P.
Rich (BB code):
Sub AddBlankRow()
Dim intLastRow As Integer
Dim i As Integer
Dim strStartCell As String
Dim j As Integer
Dim k As Currency
strStartCell = ActiveCell.Address
intLastRow = Range("A65536").End(xlUp).Row
Range("n2").Select
k = 0
j = 1
For i = 2 To intLastRow
If ActiveCell.Value <> ActiveCell.Offset(1, 0).Value Then
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Insert (xlDown)
Cells(i + j, "P") = "Sum"
Cells(i + j, "Q") = ""
j = j + 1
k = 0
End If
ActiveCell.Offset(1, 0).Select
k = k + 1
Next i
Range(strStartCell).Select
End Sub
The codes in the brackets trying to be bold are what I put in trying to make it work. Basically, I was trying to add up each of the numbers when I skip to the next row then display the sum when I insert a new row.
The names are in column A and the numbers are in column P.