Delete a row if unique event occurs only once

robertpri

New Member
Joined
Dec 16, 2004
Messages
28
We have 1,000's of rows of text data, but a huge number of rows have only one unique event.

joe called
joe called
bill called
joe called

etc. It's almost impossible to sort this data, so we're trying to find a command or macro that would delete the entire row when "bill called" because it only happened once. This scrubs our data to indicate repeat events only.

And this is always text-never numbers

Much appreciated!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Assuming the text values are identical, this should do it:
Code:
Sub delunique()
Dim rng As Range, c As Range

Set rng = Range("A2:A" & Range("A65536").End(xlUp).Row)

For i = rng.Count + 1 To 2 Step -1
Set c = Cells(i, 1)

If Application.WorksheetFunction.CountIf(rng, c.Value) = 1 Then
    c.EntireRow.Delete
End If
Next i

End Sub
HTH.
 
Upvote 0
OMG!
I am SO impressed! I don't pretend to understand it, but it works!
I could have messed with this forever and never got it.
You have no idea how much work you have saved me.

VERY much appreciated--thank you!

robertpri
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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