Find Duplicate Rows across multiple columns, sum dupes to a column, remove duplicates. VBA?

jrsmoots

New Member
Joined
Aug 8, 2019
Messages
2
I have a spreadsheet like this:

UNJobRGASTHSumDupes
L2170281B1275
L2170281C1250
L2170281C1250
L2170281C12100
L2170282A650

<tbody>
</tbody>

I need to find duplicates: duplicate in this case means that the "Job", "RG" and "AS" are identical. So in above sample the 2nd, 3rd and 4th data rows would be considered duplicates.

I need to then sum the "TH" column for these duplicates. So, 50+50+50.

I then need to remove the duplicates (consolidate?) it down to one row, that row having the total from the duplicates (the 50+50+50).

I'm pretty comfortable with VBA, less comfortable with Excel formulas. Is this procedure something I could do from within Excel, using VBA? Trying to figure out how to present this functionality to the end user too...Maybe they could run a Macro that calls a VBA function?

I try concatenating the three columns that might might be duplicates, and tried the following formulas, which work for finding duplicates

IF(COUNTIF($H$2:H2,H2)>1, " Here I am! I'm a duplicate!","Original")

And summing duplicates:
=IF(AND(COUNTIF(H$2:H2,H2)=COUNTIF(H:H,H2),COUNTIF(H:H,H2)>1),SUMIF(H:H,H2,F:F),"")

from: https://www.mrexcel.com/forum/excel...-then-sum-values-another-column-same-row.html

Thanks in advance!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi & welcome to MrExcel.
How about
Code:
Sub jrsmoots()
   Dim Cl As Range, Rng As Range
   Dim Vlu As String
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("B2", Range("B" & Rows.Count).End(xlUp))
         Vlu = Cl.Value & "|" & Cl.Offset(, 1).Value & "|" & Cl.Offset(, 2).Value
         If Not .exists(Vlu) Then
            .Add Vlu, Cl.Offset(, 3)
         Else
            .Item(Vlu).Value = .Item(Vlu) + Cl.Offset(, 3).Value
            If Rng Is Nothing Then Set Rng = Cl Else Set Rng = Union(Rng, Cl)
         End If
      Next Cl
   End With
   If Not Rng Is Nothing Then Rng.EntireRow.Delete
End Sub
 
Upvote 0
Hello,

I need to do the same but instead I have to add and sum one more cell and the end of the row.

Can you please help me??

1633016327109.png
 
Upvote 0
Hi & welcome to MrExcel.
Please start a new thread for your question. You are far more likely to get a response.
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,276
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top