Hello Everyone,
I am currently working on a macro that inserts a space between each individual person based off of their ID in column A. What I am now attempting to do is have the macro run an "autosum" function, based off of the purchases and split payment amounts in column K and L, and print the result in column P. For some reason, it is returning only one sum, which does not even match the sum of all purchases under the specific person. Below I have posted the portion of the code in question, as well as some screenshot to help illustrate my issue. Any help would be greatly appreciated.
Dim lastrow As Long
Dim x As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
For x = lastrow To 2 Step -1
If Cells(x, 1).Value <> Cells(x - 1, 1).Value Then
If Cells(x, 1).Value <> "" Then
If Cells(x - 1, 1).Value <> "" Then
Cells(x, 1).EntireRow.Insert Shift:=xlDown
End If
End If
End If
Next x
For i = 11 To 12
For class = lastrow To 2 Step -1
For Each numrange In Columns(i).SpecialCells(xlConstants, xlNumbers).Areas
If Cells(class, 7).Value <> Cells(class - 1, 7).Value Then
If Cells(class, 7).Value <> "" Then
If Cells(class - 1, 7).Value <> "" Then
sumaddr = numrange.Address(False, False)
numrange.Offset(numrange.Count, 0).Resize(1, 1).Formula = "=SUM(" & sumaddr & ")"
Cells(numrange.Cells(1, 1).Row, "P") = Cells(numrange.Cells(1, 1).Row, "P") + numrange.Offset(numrange.Count, 0).Resize(1, 1).Value
numrange.Offset(numrange.Count, 0).Resize(1, 1).Clear
c = numrange.Count
End If
End If
End If
Next numrange
Next class
Next i
Application.ScreenUpdating = True
What the macro is currently doing:
Excel 4.JPG
What I would LIKE the macro to do:
Excel 5.JPG
Bookmarks