I am starting to write some code that will take a spreadsheet with thousands of rows of project data, and delete all rows except the rows that contain the name of a specific group of individuals. My first thought is to use a For loop, with an If(AND) Then statement like the following:
There has to be a more efficient way to do this, and I would appreciate any input I can get. This may very well work, but I don't know how many ANDs I can use in an If statement.
Thanks!
Code:
For lngRow = 1 to 5000
If(Cells(lngRow,4)<>name1 AND Cells(lngRow1,4)<>name2 AND Cells(lngRow1,4)<>name3......) Then
Rows(lngRow).Delete Shift:=xlUP
lngRow = lngRow -1
End If
Next lngRow
There has to be a more efficient way to do this, and I would appreciate any input I can get. This may very well work, but I don't know how many ANDs I can use in an If statement.
Thanks!