View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Remove all duplicates and return highest value in new row

Try this small macro:

Sub nikky()
Dim v1 As String, v2 As Long
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = n To 1 Step -1
v1 = Cells(i, 1).Value
v2 = Cells(i, 2).Value
For j = n To 1 Step -1
If Cells(j, 1).Value = v1 And Cells(j, 2).Value v2 Then
Cells(i, 1).EntireRow.Delete
GoTo nextone
End If
Next
nextone:
Next
End Sub

So if we start with:

cat 1
mouse 1
dog 66
mouse 4
dog 5
mouse 2
cat 34
dog 3


the macro will produce:

dog 66
mouse 4
cat 34



--
Gary''s Student - gsnu200828


"Nikkynock" wrote:

Hi

I am looking to locate all duplicates of a descriptor in column a, remove,
and create a new row with just the descriptor and the highest value in column
b.
For example

col a col b
generice code 1 000123456
generice code 1 000123678
generice code 1 000123910

Returns:
generice code 1 000123910

...and removes all other lines

many thanks