Hello,
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 seems that is not 100%:
I also attached the file for example.
Can you take a look and explain what i am missing ?
Thanks
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 seems that is not 100%:
Code:
Sub macro1()
lastrow = Range("A1").End(xlDown).Row
For i = 1 To lastrow
For n = 1 To lastrow
If 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
End Sub
I also attached the file for example.
Can you take a look and explain what i am missing ?
Thanks