ThePangloss
New Member
- Joined
- Jun 19, 2015
- Messages
- 40
I'm looking for a way to add up the values of duplicate rows underneath the original then delete the duplicate afterwards, whether this is through VBA or just formulas. I can't really think of any way other than using the IF function such as
=IF((A2=A3)*(B2=B3),"",SUM(C$<wbr style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; line-height: 16.8999996185303px; white-space: pre-wrap;">2:C2)-SUM(D$1:D1))
but this only works for rows that have only one duplicate row. Some of my data has three to five duplicate rows with values that I need to sum up in the main one. The rows I have are last name, first name, id number, then hours worked. Some people worked different jobs at different periods so they come up multiple times. I need to add up their total hours.
An example looks like this
[TABLE="width: 500"]
<tbody>[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]bob marley[/TD]
[TD]238281[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]jane doe[/TD]
[TD]91919[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]jane doe[/TD]
[TD]91919[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]mark john[/TD]
[TD]383282[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]
which I need to turn into
[TABLE="width: 500"]
<tbody>[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]39[/TD]
[/TR]
[TR]
[TD]bob marley[/TD]
[TD]238281[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]jane doe[/TD]
[TD]91919[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]mark john[/TD]
[TD]383282[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]
I'd appreciate any advice on this. Thanks in advance.
=IF((A2=A3)*(B2=B3),"",SUM(C$<wbr style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; line-height: 16.8999996185303px; white-space: pre-wrap;">2:C2)-SUM(D$1:D1))
but this only works for rows that have only one duplicate row. Some of my data has three to five duplicate rows with values that I need to sum up in the main one. The rows I have are last name, first name, id number, then hours worked. Some people worked different jobs at different periods so they come up multiple times. I need to add up their total hours.
An example looks like this
[TABLE="width: 500"]
<tbody>[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]8[/TD]
[/TR]
[TR]
[TD]bob marley[/TD]
[TD]238281[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]jane doe[/TD]
[TD]91919[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]jane doe[/TD]
[TD]91919[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]mark john[/TD]
[TD]383282[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]
which I need to turn into
[TABLE="width: 500"]
<tbody>[TR]
[TD]john doe[/TD]
[TD]128128[/TD]
[TD]39[/TD]
[/TR]
[TR]
[TD]bob marley[/TD]
[TD]238281[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]jane doe[/TD]
[TD]91919[/TD]
[TD]17[/TD]
[/TR]
[TR]
[TD]mark john[/TD]
[TD]383282[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]
I'd appreciate any advice on this. Thanks in advance.