Retain if atleast 4 entries
Randy,
assuming your data is sorted in numerical order by company
and the starts in cell A2, this very crude bit of code
will do the job:
Sub DeleteCompanies()
LastRow = ActiveSheet.UsedRange.Count
For x = 2 To LastRow
HowMany = Application.WorksheetFunction.CountIf(Range_
(Cells(x, 1), Cells(LastRow, 1)), Cells(x, 1).Value) - 1
If HowMany < 3 Then
For z = (x + HowMany) To x Step -1
Rows(z).Delete
Next z
LastRow = LastRow - HowMany
x = x - 1
Else
x = x + HowMany
End If
Next x
End Sub
I would save a copy before you start deleting though!
Pete
I have a unique problem here. I have got an excel file
with almost 2500 rows of data in it. Coulumn "A" contains
the ID # of companies. Each company might have more than
one data entry (row),
What i need to do is to write a program which will look
at the first column of ID#s and if the ID# occurs less
than 4 times, i delete those rows.
|