0

So basically I will have a changing list of names entered like so

Deborah     9   30

Steven      4   22

Michelle    9   26

Michelle    8   30

Alice      10   28

John        3   21

David       7   23

David       9   26

David       7   24

Lucy        6   24

and my goal is to write a macros so that the names appear like this

Deborah     9   30

Steven      4   22

Michelle    17  56

Alice       10  28

John        3   21

David       23  73

Lucy        6   24

so all the rows with the same value for column 1 will be a sum of the values in the other column and consolidated to one row. The names are going to be changing, so I cant hardcode in IF something = "Michelle" it has to just be IF these rows = these other rows. I am trying to automate a tedious task at work, thanks for any suggestions!

Ravi Yenugu
  • 3,895
  • 5
  • 40
  • 58

3 Answers3

0

You can create a distinct sorted list of names using an array formula with INDEX, MATCH, MAX and COUNTIF as described here:

http://www.get-digital-help.com/2009/04/14/create-a-unique-alphabetically-sorted-list-extracted-from-a-column/

Then you can just use a simple SUMIF function for each name in the result.

dePatinkin
  • 2,239
  • 1
  • 16
  • 15
0

If the duplicated names are in consecutive rows, then try this short macro:

Sub DeDup()
    Dim N As Long, i As Long
    N = Cells(Rows.Count, "A").End(xlUp).Row
    For i = N To 2 Step -1
        If Cells(i, 1) = Cells(i - 1, 1) Then
            Cells(i - 1, 2) = Cells(i - 1, 2) + Cells(i, 2)
            Cells(i - 1, 3) = Cells(i - 1, 3) + Cells(i, 3)
            Range(Cells(i, 1), Cells(i, 3)).Delete Shift:=xlUp
        End If
    Next i
End Sub
Gary's Student
  • 95,722
  • 10
  • 59
  • 99
0

Just use a sumif formula. you can manipulate it to your needs. It will sum what you want in a given row. Or use an array if you would like.

acoopie89
  • 13
  • 4