I made a macro that should cumulate the items from a Timesheet Export: for example if the value from cell (2,21) is the same with the value from cell (1,21) then sum the amount from cell (2,12) to cell (1,12) and delete the entire row of cell (2,21).

Untill now my macro does something, but it's not 100% what i want because i have to run it more times to delete all the duplicate items. The question is how to do so the loop will continue to next combination without stopping ? (if there are more then 2 same items)

Dim i As Integer
Dim n As Integer

lastrow = Range("A1").End(xlDown).Row

For i = 1 To lastrow
    
    For n = 1 To lastrow
    
If Cells(i, 21) = "" Then
Exit For

ElseIf Cells(i + n, 21) = Cells(i, 21) Then  'if the values from column 21 are the same then cumulate items

'sum the values from row i+n on row i
Cells(i, 12).Value = Cells(i, 12).Value + Cells(i + n, 12).Value
'put the text from row i+n on row n with ";" separator
Cells(i, 18) = Cells(i, 18) & "; " & Cells(i + n, 18)

'delete row i+n
Cells(i + n, 1).Select
Selection.EntireRow.Delete

End If

    Next n
    
Next i
Cumulate items macro- example (1).xlsm


Thanks a lot !