Macro to keep 15 specific records and delete 1000 other rows.
As a starter
Sub Test()
Dim iLastRow As Long
Dim i As Long
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
For i = iLastRow To 1 Step -1
Select Case Cells(i, "A").Value
Case "value 1", "value 2", "value 3", _
"value 4", "value 5", "value 6", _
"value 7", "value 8", "value 9", _
"value 10", "value 11", "value 12", _
"value 13", "value 14", "value 15":
Case Else: Rows(i).Delete
End Select
Next i
Application.ScreenUpdating = True
End Sub
--
HTH
Bob Phillips
(replace somewhere in email address with gmail if mailing direct)
"Sam" wrote in message
ps.com...
Hi Gang,
I work inventory control for a company in Texas and have to check stock
levels for around 15 parts daily. The download for these parts contain
an additional 1000 other rows of part numbers I dont need. I have used
Excel macros in the past that delete rows based on specific criteria
but how
do I do the reverse? Essentially use a macro that says "keep these 15
specific part numbers" but delete everything else that isnt them. I
posted this question mistakenly in an Access forum so my aplogies if
this looks like a double post.
Your help is greatly appreciated.
Sam
|