Find all from a list

G

Guest

I have data that I past into a spread sheet that I download daily of over
1000 rows with names and data columns. I have a list of 15 people listed on
this list that I need to find their records, delete the others and end up
with only those 15 peoples data. What is the best way for me to accomplish
this.
 
R

Ron de Bruin

Hi

You can try this one with the names in column A
Enter all names in the array
Array("jelle", "ron", "dave")

you can also make a list on a worksheet if you want

Sub Example2()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 1
EndRow = 1000
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the cell

ElseIf IsError(Application.Match(.Cells(Lrow, "A").Value, _
Array("jelle", "ron", "dave"), 0)) Then .Rows(Lrow).Delete

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top