Compare if current row is different or the same with the previous row

Hello.

Need some help with my current project.

Note: The datatable has been sorted so the names are arranged based on their value.

Tasks:

  1. Check if the current value in Column A (“Name”) is the same or different with the next value.
    1.1 - If the same, get total amount of the values with the same name (could be more than 2
    names with the same value). The total amount will be entered in the system.
    1.2 If not the same, just get the amount of the name.

Current problem: Names “A” and “B” are unique but once the bot compares the next row which is “C” and the next row again is “C”, the bot should get the total amount and not compare “C” which is the current row to “B” which is the previous row. The bot should be able to identify if the current row and the succeeding rows have the same value or not.

image