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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

martinee

Well-known Member
Joined
Nov 4, 2003
Messages
960
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.
 

robertpri

New Member
Joined
Dec 16, 2004
Messages
28
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
 

Forum statistics

Threads
1,147,847
Messages
5,743,522
Members
423,801
Latest member
paulj4177

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
Top