do not delete rows in a list.

G

Guest

Hello

unlike most of the post I'd lke the code to a macro that does not delete
rows. To be more specific I'd like my macro to check the values of column E
of the list, for 3 criteria, and if any of the three exist then to KEEP these
rows and delete all the others.


I guess it would have to be a macro similar to the one found at
http://www.rondebruin.nl/delete.htm only instead of deleting the rows that
meet the criteria, keep these rows and delete the rest.

any help apreciated

Steven.
 
D

Don Guillett

one way
Sub deleteifnot()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = lr To 4 Step -1
If Cells(i, "a") <> "a" And _
Cells(i, "a") <> "b" And _
Cells(i, "a") <> "c" Then Rows(i).Delete
Next i
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

Similar Threads


Top