Sub TidyData()
Dim iLastRow As Long
Dim i As Long
Dim j As Long
Dim iRow
Dim sFormula As String
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
j = 0
For i = 1 To iLastRow
On Error Resume Next
iRow = Application.Match(Cells(i, "A").Value, Columns(3), 0)
If IsError(iRow) Then
j = j + 1
Cells(j, "C").Value = Cells(i, "A").Value
sFormula = "SUMPRODUCT(--(A1:A" & iLastRow & "=""" & Cells(i,
"A").Value & """)," & "B1:B" & iLastRow & ")"
Cells(j, "D").Value = Evaluate(sFormula)
End If
Next i
Columns("A:B").Delete
End Sub
--
HTH
RP
(remove nothere from the email address if mailing direct)
"bao-bao" wrote in message
...
Hi, I have a talbe including two or more same name, I
want to make it from:
tom 10
Mike 10
tom 20
jerry 30
to:
tom 30
Mike 10
jerry 30
Please help, Thank you!
|