View Single Post
  #7   Report Post  
Bob Phillips
 
Posts: n/a
Default Delete rows listed less than 8 times???

Hi Amanda,

This should do it

Sub Redundancy()
Dim iLastrow As Long
Dim i As Long
Dim rng As Range
Dim iStart As Long
Dim iEnd As Long
Dim sTemp

iLastrow = Cells(Rows.Count, "A").End(xlUp).Row
Rows(1).Resize(iLastrow).Sort key1:=Range("A1"), header:=xlGuess
iStart = 1: sTemp = Range("A1").Value
For i = 2 To iLastrow
If Cells(i, "A").Value < sTemp Then
iEnd = i - 1
If i - iStart < 8 Then
If rng Is Nothing Then
Set rng = Rows(iStart & ":" & iEnd)
Else
Set rng = Union(rng, Rows(iStart & ":" & iEnd))
End If
End If
iStart = i
sTemp = Cells(i, "A").Value
End If
Next i

If Not rng Is Nothing Then
rng.Delete
End If

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"anilos81" wrote in
message ...

OK, so here is my problem:

I am at work and have to take spreadsheets with about 25,000 rows of
data and delete any records that appear less than 8 times.

To be more specific, I have three columns:

name
office
phone number

When I sort it by name John Doe might appear 10 times while Jane Doe
only appears twice. Because Jane Doe is coming up LESS THAN 8 times
all of her rows need to be deleted.

Can someone please help because this is an ongoing project and I can't
see my company wasting the man hours to do it manually!

Let me know if I haven't explained well enough and I'll try to clarify.


Amanda


--
anilos81
------------------------------------------------------------------------
anilos81's Profile:

http://www.excelforum.com/member.php...o&userid=28687
View this thread: http://www.excelforum.com/showthread...hreadid=483688