getting rid of multiple entries of the same name but adding a value together

Ivn68

Board Regular
Joined
Aug 21, 2015
Messages
70
in columnA I have a name and in columnB I have a value
there would be multiple entries for the same name but different values in columnB
i need to get rid of the duplicate entry but the values in columnB to be added together

thinkng im gonna need to run a loop in vba
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Ivn68,

So that we can get it right on the first try, can we see your actual raw data workbook/worksheet, and, can we see what the results (manually formatted by you) should look like?

You can post your workbook/worksheets to the following free site (sensitive data changed), mark the workbook for sharing, and, provide us with a link to your workbook:

https://dropbox.com
 
Upvote 0
How about
Code:
Sub Totalunique()

   Dim cl As Range
   
   With CreateObject("scripting.dictionary")
      For Each cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
         If Not .exists(cl.Value) Then
            .Add cl.Value, cl.Offset(, 1).Value
         Else
            .Item(cl.Value) = .Item(cl.Value) + cl.Offset(, 1).Value
         End If
      Next cl
      Range("A1").CurrentRegion.Offset(1).ClearContents
      Range("A2").Resize(.Count).Value = Application.Transpose(.keys)
      Range("B2").Resize(.Count).Value = Application.Transpose(.items)
   End With
End Sub
 
Upvote 0
in columnA it only added 2 entries at a time
so if i have the same name 4 times i end up with 2 entries i only want one
 
Upvote 0
How about
Code:
Sub Totalunique()

   Dim cl As Range
   
   With CreateObject("scripting.dictionary")
     [COLOR=#ff0000] .CompareMode = vbTextCompare[/COLOR]
      For Each cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
         If Not .exists(cl.Value) Then
            .Add cl.Value, cl.Offset(, 1).Value
         Else
            .Item(cl.Value) = .Item(cl.Value) + cl.Offset(, 1).Value
         End If
      Next cl
      Range("A1").CurrentRegion.Offset(1).ClearContents
      Range("A2").Resize(.Count).Value = Application.Transpose(.keys)
      Range("B2").Resize(.Count).Value = Application.Transpose(.items)
   End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Like this
Code:
   For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
     If Not .exists(Cl.Value) Then
        .Add Cl.Value, Cl.Offset(, [COLOR=#ff0000]2[/COLOR]).Value
     Else
        .Item(Cl.Value) = .Item(Cl.Value) + Cl.Offset(, [COLOR=#ff0000]2[/COLOR]).Value
     End If
   Next Cl
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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